Date: Fri, 29 Dec 2017 00:56:15 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r327330 - in projects/clang600-import: contrib/compiler-rt/lib/sanitizer_common contrib/compiler-rt/lib/tsan/rtl contrib/compiler-rt/lib/ubsan contrib/libc++/src/experimental/filesystem... Message-ID: <201712290056.vBT0uFVp013200@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Fri Dec 29 00:56:15 2017 New Revision: 327330 URL: https://svnweb.freebsd.org/changeset/base/327330 Log: Merge llvm, clang, lld, lldb, compiler-rt and libc++ trunk r321545, update build glue and version numbers, add new intrinsics headers, and update OptionalObsoleteFiles.inc. Added: projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512bitalgintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512bitalgintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512vbmi2intrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512vbmi2intrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512vlbitalgintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512vlbitalgintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512vlvbmi2intrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512vlvbmi2intrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512vlvnniintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512vlvnniintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/avx512vnniintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/avx512vnniintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/gfniintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/gfniintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/vaesintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/vaesintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/vpclmulqdqintrin.h - copied unchanged from r327329, vendor/clang/dist/lib/Headers/vpclmulqdqintrin.h Modified: projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h projects/clang600-import/contrib/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc projects/clang600-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.cc projects/clang600-import/contrib/libc++/src/experimental/filesystem/operations.cpp projects/clang600-import/contrib/llvm/include/llvm/Analysis/InstructionSimplify.h projects/clang600-import/contrib/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfo.h projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h projects/clang600-import/contrib/llvm/include/llvm/BinaryFormat/COFF.h projects/clang600-import/contrib/llvm/include/llvm/CodeGen/BasicTTIImpl.h projects/clang600-import/contrib/llvm/include/llvm/IR/IntrinsicsAMDGPU.td projects/clang600-import/contrib/llvm/include/llvm/ProfileData/SampleProf.h projects/clang600-import/contrib/llvm/include/llvm/Support/KnownBits.h projects/clang600-import/contrib/llvm/lib/Analysis/DemandedBits.cpp projects/clang600-import/contrib/llvm/lib/Analysis/InstructionSimplify.cpp projects/clang600-import/contrib/llvm/lib/Analysis/Lint.cpp projects/clang600-import/contrib/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp projects/clang600-import/contrib/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp projects/clang600-import/contrib/llvm/lib/Analysis/TargetTransformInfo.cpp projects/clang600-import/contrib/llvm/lib/Analysis/ValueTracking.cpp projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp projects/clang600-import/contrib/llvm/lib/IR/SafepointIRVerifier.cpp projects/clang600-import/contrib/llvm/lib/LTO/LTOModule.cpp projects/clang600-import/contrib/llvm/lib/LTO/ThinLTOCodeGenerator.cpp projects/clang600-import/contrib/llvm/lib/MC/MCParser/DarwinAsmParser.cpp projects/clang600-import/contrib/llvm/lib/MC/MCParser/ELFAsmParser.cpp projects/clang600-import/contrib/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp projects/clang600-import/contrib/llvm/lib/Support/ARMAttributeParser.cpp projects/clang600-import/contrib/llvm/lib/Support/CommandLine.cpp projects/clang600-import/contrib/llvm/lib/TableGen/Main.cpp projects/clang600-import/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp projects/clang600-import/contrib/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp projects/clang600-import/contrib/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp projects/clang600-import/contrib/llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp projects/clang600-import/contrib/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp projects/clang600-import/contrib/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp projects/clang600-import/contrib/llvm/lib/Target/X86/X86.td projects/clang600-import/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp projects/clang600-import/contrib/llvm/lib/Target/X86/X86ISelLowering.h projects/clang600-import/contrib/llvm/lib/Target/X86/X86InstrAVX512.td projects/clang600-import/contrib/llvm/lib/Target/X86/X86InstrFPStack.td projects/clang600-import/contrib/llvm/lib/Target/X86/X86InstrInfo.td projects/clang600-import/contrib/llvm/lib/Target/X86/X86InstrSSE.td projects/clang600-import/contrib/llvm/lib/Target/X86/X86WinEHState.cpp projects/clang600-import/contrib/llvm/lib/Transforms/IPO/SampleProfile.cpp projects/clang600-import/contrib/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp projects/clang600-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp projects/clang600-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp projects/clang600-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Scalar/GVNSink.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Utils/LoopUtils.cpp projects/clang600-import/contrib/llvm/lib/Transforms/Utils/SimplifyCFG.cpp projects/clang600-import/contrib/llvm/tools/clang/include/clang/AST/Stmt.h projects/clang600-import/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def projects/clang600-import/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td projects/clang600-import/contrib/llvm/tools/clang/include/clang/Driver/Options.td projects/clang600-import/contrib/llvm/tools/clang/include/clang/Parse/Parser.h projects/clang600-import/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/AST/Decl.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/AST/Stmt.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Basic/Targets/AArch64.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Basic/Targets/ARM.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Basic/Targets/X86.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Basic/Targets/X86.h projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGExpr.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h projects/clang600-import/contrib/llvm/tools/clang/lib/Driver/SanitizerArgs.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Driver/ToolChains/CommonArgs.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Driver/ToolChains/Hexagon.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Headers/immintrin.h projects/clang600-import/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Parse/Parser.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaLookup.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp projects/clang600-import/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp projects/clang600-import/contrib/llvm/tools/clang/utils/TableGen/NeonEmitter.cpp projects/clang600-import/contrib/llvm/tools/lld/COFF/Config.h projects/clang600-import/contrib/llvm/tools/lld/COFF/Driver.cpp projects/clang600-import/contrib/llvm/tools/lld/COFF/Driver.h projects/clang600-import/contrib/llvm/tools/lld/COFF/DriverUtils.cpp projects/clang600-import/contrib/llvm/tools/lld/COFF/Options.td projects/clang600-import/contrib/llvm/tools/lld/COFF/SymbolTable.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/Arch/X86.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/Arch/X86_64.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/LinkerScript.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/Relocations.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/ScriptLexer.cpp projects/clang600-import/contrib/llvm/tools/lld/ELF/ScriptParser.cpp projects/clang600-import/contrib/llvm/tools/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h projects/clang600-import/contrib/llvm/tools/llvm-cov/CodeCoverage.cpp projects/clang600-import/contrib/llvm/tools/llvm-objdump/llvm-objdump.cpp projects/clang600-import/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp projects/clang600-import/contrib/llvm/tools/llvm-readobj/ELFDumper.cpp projects/clang600-import/contrib/llvm/utils/TableGen/CodeGenDAGPatterns.cpp projects/clang600-import/contrib/llvm/utils/TableGen/DFAPacketizerEmitter.cpp projects/clang600-import/contrib/llvm/utils/TableGen/IntrinsicEmitter.cpp projects/clang600-import/lib/clang/headers/Makefile projects/clang600-import/lib/clang/include/clang/Basic/Version.inc projects/clang600-import/lib/clang/include/lld/Common/Version.inc projects/clang600-import/lib/clang/include/llvm/Support/VCSRevision.h projects/clang600-import/tools/build/mk/OptionalObsoleteFiles.inc Directory Properties: projects/clang600-import/contrib/compiler-rt/ (props changed) projects/clang600-import/contrib/libc++/ (props changed) projects/clang600-import/contrib/llvm/ (props changed) projects/clang600-import/contrib/llvm/tools/clang/ (props changed) projects/clang600-import/contrib/llvm/tools/lld/ (props changed) projects/clang600-import/contrib/llvm/tools/lldb/ (props changed) Modified: projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc ============================================================================== --- projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc Fri Dec 29 00:56:15 2017 (r327330) @@ -4551,6 +4551,20 @@ INTERCEPTOR(int, pthread_setname_np, uptr thread, cons #define INIT_PTHREAD_SETNAME_NP #endif +#if SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP +INTERCEPTOR(int, pthread_getname_np, uptr thread, char *name, SIZE_T len) { + void *ctx; + COMMON_INTERCEPTOR_ENTER(ctx, pthread_getname_np, thread, name, len); + int res = REAL(pthread_getname_np)(thread, name, len); + if (!res) + COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, internal_strnlen(name, len) + 1); + return res; +} +#define INIT_PTHREAD_GETNAME_NP COMMON_INTERCEPT_FUNCTION(pthread_getname_np); +#else +#define INIT_PTHREAD_GETNAME_NP +#endif + #if SANITIZER_INTERCEPT_SINCOS INTERCEPTOR(void, sincos, double x, double *sin, double *cos) { void *ctx; @@ -6541,6 +6555,7 @@ static void InitializeCommonInterceptors() { INIT_TTYNAME_R; INIT_TEMPNAM; INIT_PTHREAD_SETNAME_NP; + INIT_PTHREAD_GETNAME_NP; INIT_SINCOS; INIT_REMQUO; INIT_LGAMMA; Modified: projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h ============================================================================== --- projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h Fri Dec 29 00:56:15 2017 (r327330) @@ -343,6 +343,8 @@ #define SANITIZER_INTERCEPT_PHTREAD_MUTEX SI_POSIX #define SANITIZER_INTERCEPT_PTHREAD_SETNAME_NP \ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) +#define SANITIZER_INTERCEPT_PTHREAD_GETNAME_NP \ + (SI_FREEBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) #define SANITIZER_INTERCEPT_TLS_GET_ADDR \ (SI_FREEBSD || SI_NETBSD || SI_LINUX_NOT_ANDROID || SI_SOLARIS) Modified: projects/clang600-import/contrib/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc ============================================================================== --- projects/clang600-import/contrib/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc Fri Dec 29 00:56:15 2017 (r327330) @@ -25,6 +25,11 @@ #include <dispatch/dispatch.h> #include <pthread.h> +// DISPATCH_NOESCAPE is not defined prior to XCode 8. +#ifndef DISPATCH_NOESCAPE +#define DISPATCH_NOESCAPE +#endif + typedef long long_t; // NOLINT namespace __tsan { Modified: projects/clang600-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.cc ============================================================================== --- projects/clang600-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.cc Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.cc Fri Dec 29 00:56:15 2017 (r327330) @@ -38,7 +38,8 @@ bool ignoreReport(SourceLocation SLoc, ReportOptions O const char *TypeCheckKinds[] = { "load of", "store to", "reference binding to", "member access within", "member call on", "constructor call on", "downcast of", "downcast of", - "upcast of", "cast to virtual base of", "_Nonnull binding to"}; + "upcast of", "cast to virtual base of", "_Nonnull binding to", + "dynamic operation on"}; } static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer, Modified: projects/clang600-import/contrib/libc++/src/experimental/filesystem/operations.cpp ============================================================================== --- projects/clang600-import/contrib/libc++/src/experimental/filesystem/operations.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/libc++/src/experimental/filesystem/operations.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -512,6 +512,7 @@ using StatT = struct stat; #if defined(__APPLE__) TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; } +__attribute__((unused)) // Suppress warning TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; } #else TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; } Modified: projects/clang600-import/contrib/llvm/include/llvm/Analysis/InstructionSimplify.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/Analysis/InstructionSimplify.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/Analysis/InstructionSimplify.h Fri Dec 29 00:56:15 2017 (r327330) @@ -197,6 +197,9 @@ Value *SimplifyBinOp(unsigned Opcode, Value *LHS, Valu Value *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS, FastMathFlags FMF, const SimplifyQuery &Q); +/// Given a callsite, fold the result or return null. +Value *SimplifyCall(ImmutableCallSite CS, const SimplifyQuery &Q); + /// Given a function and iterators over arguments, fold the result or return /// null. Value *SimplifyCall(ImmutableCallSite CS, Value *V, User::op_iterator ArgBegin, Modified: projects/clang600-import/contrib/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h Fri Dec 29 00:56:15 2017 (r327330) @@ -407,12 +407,6 @@ class MemoryDependenceResults { (public) void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl<NonLocalDepResult> &Result); - /// Perform a dependency query specifically for QueryInst's access to Loc. - /// The other comments for getNonLocalPointerDependency apply here as well. - void getNonLocalPointerDependencyFrom(Instruction *QueryInst, - const MemoryLocation &Loc, bool isLoad, - SmallVectorImpl<NonLocalDepResult> &Result); - /// Removes an instruction from the dependence analysis, updating the /// dependence of instructions that previously depended on it. void removeInstruction(Instruction *InstToRemove); Modified: projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfo.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfo.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfo.h Fri Dec 29 00:56:15 2017 (r327330) @@ -646,9 +646,6 @@ class TargetTransformInfo { (public) /// \brief Additional properties of an operand's values. enum OperandValueProperties { OP_None = 0, OP_PowerOf2 = 1 }; - /// \return True if target can execute instructions out of order. - bool isOutOfOrder() const; - /// \return The number of scalar or vector registers that the target has. /// If 'Vectors' is true, it returns the number of vector registers. If it is /// set to false, it returns the number of scalar registers. @@ -1021,7 +1018,6 @@ class TargetTransformInfo::Concept { (public) Type *Ty) = 0; virtual int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty) = 0; - virtual bool isOutOfOrder() const = 0; virtual unsigned getNumberOfRegisters(bool Vector) = 0; virtual unsigned getRegisterBitWidth(bool Vector) const = 0; virtual unsigned getMinVectorRegisterBitWidth() = 0; @@ -1298,9 +1294,6 @@ class TargetTransformInfo::Model final : public Target int getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty) override { return Impl.getIntImmCost(IID, Idx, Imm, Ty); - } - bool isOutOfOrder() const override { - return Impl.isOutOfOrder(); } unsigned getNumberOfRegisters(bool Vector) override { return Impl.getNumberOfRegisters(Vector); Modified: projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h Fri Dec 29 00:56:15 2017 (r327330) @@ -337,8 +337,6 @@ class TargetTransformInfoImplBase { (public) return TTI::TCC_Free; } - bool isOutOfOrder() const { return false; } - unsigned getNumberOfRegisters(bool Vector) { return 8; } unsigned getRegisterBitWidth(bool Vector) const { return 32; } Modified: projects/clang600-import/contrib/llvm/include/llvm/BinaryFormat/COFF.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/BinaryFormat/COFF.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/BinaryFormat/COFF.h Fri Dec 29 00:56:15 2017 (r327330) @@ -95,7 +95,7 @@ enum MachineTypes : unsigned { MT_Invalid = 0xffff, IMAGE_FILE_MACHINE_UNKNOWN = 0x0, - IMAGE_FILE_MACHINE_AM33 = 0x13, + IMAGE_FILE_MACHINE_AM33 = 0x1D3, IMAGE_FILE_MACHINE_AMD64 = 0x8664, IMAGE_FILE_MACHINE_ARM = 0x1C0, IMAGE_FILE_MACHINE_ARMNT = 0x1C4, Modified: projects/clang600-import/contrib/llvm/include/llvm/CodeGen/BasicTTIImpl.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/CodeGen/BasicTTIImpl.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/CodeGen/BasicTTIImpl.h Fri Dec 29 00:56:15 2017 (r327330) @@ -402,10 +402,6 @@ class BasicTTIImplBase : public TargetTransformInfoImp return BaseT::getInstructionLatency(I); } - bool isOutOfOrder() const { - return getST()->getSchedModel().isOutOfOrder(); - } - /// @} /// \name Vector TTI Implementations Modified: projects/clang600-import/contrib/llvm/include/llvm/IR/IntrinsicsAMDGPU.td ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/IR/IntrinsicsAMDGPU.td Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/IR/IntrinsicsAMDGPU.td Fri Dec 29 00:56:15 2017 (r327330) @@ -288,7 +288,8 @@ class AMDGPUAtomicIncIntrin : Intrinsic<[llvm_anyint_t llvm_i32_ty, // ordering llvm_i32_ty, // scope llvm_i1_ty], // isVolatile - [IntrArgMemOnly, NoCapture<0>] + [IntrArgMemOnly, NoCapture<0>], "", + [SDNPMemOperand] >; def int_amdgcn_atomic_inc : AMDGPUAtomicIncIntrin; Modified: projects/clang600-import/contrib/llvm/include/llvm/ProfileData/SampleProf.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/ProfileData/SampleProf.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/ProfileData/SampleProf.h Fri Dec 29 00:56:15 2017 (r327330) @@ -226,8 +226,8 @@ class FunctionSamples { (public) sampleprof_error addCalledTargetSamples(uint32_t LineOffset, uint32_t Discriminator, - const std::string &FName, - uint64_t Num, uint64_t Weight = 1) { + StringRef FName, uint64_t Num, + uint64_t Weight = 1) { return BodySamples[LineLocation(LineOffset, Discriminator)].addCalledTarget( FName, Num, Weight); } Modified: projects/clang600-import/contrib/llvm/include/llvm/Support/KnownBits.h ============================================================================== --- projects/clang600-import/contrib/llvm/include/llvm/Support/KnownBits.h Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/include/llvm/Support/KnownBits.h Fri Dec 29 00:56:15 2017 (r327330) @@ -100,13 +100,11 @@ struct KnownBits { (public) /// Make this value negative. void makeNegative() { - assert(!isNonNegative() && "Can't make a non-negative value negative"); One.setSignBit(); } /// Make this value negative. void makeNonNegative() { - assert(!isNegative() && "Can't make a negative value non-negative"); Zero.setSignBit(); } Modified: projects/clang600-import/contrib/llvm/lib/Analysis/DemandedBits.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/DemandedBits.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/DemandedBits.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -385,8 +385,8 @@ bool DemandedBits::isInstructionDead(Instruction *I) { void DemandedBits::print(raw_ostream &OS) { performAnalysis(); for (auto &KV : AliveBits) { - OS << "DemandedBits: 0x" << utohexstr(KV.second.getLimitedValue()) << " for " - << *KV.first << "\n"; + OS << "DemandedBits: 0x" << Twine::utohexstr(KV.second.getLimitedValue()) + << " for " << *KV.first << '\n'; } } Modified: projects/clang600-import/contrib/llvm/lib/Analysis/InstructionSimplify.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/InstructionSimplify.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/InstructionSimplify.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -3897,8 +3897,9 @@ static Value *SimplifyExtractElementInst(Value *Vec, V // If extracting a specified index from the vector, see if we can recursively // find a previously computed scalar that was inserted into the vector. if (auto *IdxC = dyn_cast<ConstantInt>(Idx)) - if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue())) - return Elt; + if (IdxC->getValue().ule(Vec->getType()->getVectorNumElements())) + if (Value *Elt = findScalarElement(Vec, IdxC->getZExtValue())) + return Elt; // An undef extract index can be arbitrarily chosen to be an out-of-range // index value, which would result in the instruction being undef. @@ -4494,6 +4495,22 @@ static Value *SimplifyIntrinsic(Function *F, IterTy Ar return *ArgBegin; return nullptr; } + case Intrinsic::bswap: { + Value *IIOperand = *ArgBegin; + Value *X = nullptr; + // bswap(bswap(x)) -> x + if (match(IIOperand, m_BSwap(m_Value(X)))) + return X; + return nullptr; + } + case Intrinsic::bitreverse: { + Value *IIOperand = *ArgBegin; + Value *X = nullptr; + // bitreverse(bitreverse(x)) -> x + if (match(IIOperand, m_BitReverse(m_Value(X)))) + return X; + return nullptr; + } default: return nullptr; } @@ -4548,6 +4565,16 @@ static Value *SimplifyIntrinsic(Function *F, IterTy Ar return SimplifyRelativeLoad(C0, C1, Q.DL); return nullptr; } + case Intrinsic::powi: + if (ConstantInt *Power = dyn_cast<ConstantInt>(RHS)) { + // powi(x, 0) -> 1.0 + if (Power->isZero()) + return ConstantFP::get(LHS->getType(), 1.0); + // powi(x, 1) -> x + if (Power->isOne()) + return LHS; + } + return nullptr; default: return nullptr; } @@ -4616,6 +4643,12 @@ Value *llvm::SimplifyCall(ImmutableCallSite CS, Value return ::SimplifyCall(CS, V, Args.begin(), Args.end(), Q, RecursionLimit); } +Value *llvm::SimplifyCall(ImmutableCallSite ICS, const SimplifyQuery &Q) { + CallSite CS(const_cast<Instruction*>(ICS.getInstruction())); + return ::SimplifyCall(CS, CS.getCalledValue(), CS.arg_begin(), CS.arg_end(), + Q, RecursionLimit); +} + /// See if we can compute a simplified version of this instruction. /// If not, this returns null. @@ -4750,8 +4783,7 @@ Value *llvm::SimplifyInstruction(Instruction *I, const break; case Instruction::Call: { CallSite CS(cast<CallInst>(I)); - Result = SimplifyCall(CS, CS.getCalledValue(), CS.arg_begin(), CS.arg_end(), - Q); + Result = SimplifyCall(CS, Q); break; } #define HANDLE_CAST_INST(num, opc, clas) case Instruction::opc: Modified: projects/clang600-import/contrib/llvm/lib/Analysis/Lint.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/Lint.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/Lint.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -265,13 +265,21 @@ void Lint::visitCallSite(CallSite CS) { // Check that noalias arguments don't alias other arguments. This is // not fully precise because we don't know the sizes of the dereferenced // memory regions. - if (Formal->hasNoAliasAttr() && Actual->getType()->isPointerTy()) - for (CallSite::arg_iterator BI = CS.arg_begin(); BI != AE; ++BI) + if (Formal->hasNoAliasAttr() && Actual->getType()->isPointerTy()) { + AttributeList PAL = CS.getAttributes(); + unsigned ArgNo = 0; + for (CallSite::arg_iterator BI = CS.arg_begin(); BI != AE; ++BI) { + // Skip ByVal arguments since they will be memcpy'd to the callee's + // stack so we're not really passing the pointer anyway. + if (PAL.hasParamAttribute(ArgNo++, Attribute::ByVal)) + continue; if (AI != BI && (*BI)->getType()->isPointerTy()) { AliasResult Result = AA->alias(*AI, *BI); Assert(Result != MustAlias && Result != PartialAlias, "Unusual: noalias argument aliases another argument", &I); } + } + } // Check that an sret argument points to valid memory. if (Formal->hasStructRetAttr() && Actual->getType()->isPointerTy()) { Modified: projects/clang600-import/contrib/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -920,14 +920,6 @@ void MemoryDependenceResults::getNonLocalPointerDepend Instruction *QueryInst, SmallVectorImpl<NonLocalDepResult> &Result) { const MemoryLocation Loc = MemoryLocation::get(QueryInst); bool isLoad = isa<LoadInst>(QueryInst); - return getNonLocalPointerDependencyFrom(QueryInst, Loc, isLoad, Result); -} - -void MemoryDependenceResults::getNonLocalPointerDependencyFrom( - Instruction *QueryInst, - const MemoryLocation &Loc, - bool isLoad, - SmallVectorImpl<NonLocalDepResult> &Result) { BasicBlock *FromBB = QueryInst->getParent(); assert(FromBB); @@ -1127,15 +1119,21 @@ bool MemoryDependenceResults::getNonLocalPointerDepFro // If we already have a cache entry for this CacheKey, we may need to do some // work to reconcile the cache entry and the current query. if (!Pair.second) { - if (CacheInfo->Size != Loc.Size) { - // The query's Size differs from the cached one. Throw out the - // cached data and proceed with the query at the new size. + if (CacheInfo->Size < Loc.Size) { + // The query's Size is greater than the cached one. Throw out the + // cached data and proceed with the query at the greater size. CacheInfo->Pair = BBSkipFirstBlockPair(); CacheInfo->Size = Loc.Size; for (auto &Entry : CacheInfo->NonLocalDeps) if (Instruction *Inst = Entry.getResult().getInst()) RemoveFromReverseMap(ReverseNonLocalPtrDeps, Inst, CacheKey); CacheInfo->NonLocalDeps.clear(); + } else if (CacheInfo->Size > Loc.Size) { + // This query's Size is less than the cached one. Conservatively restart + // the query using the greater size. + return getNonLocalPointerDepFromBB( + QueryInst, Pointer, Loc.getWithNewSize(CacheInfo->Size), isLoad, + StartBB, Result, Visited, SkipFirstBlock); } // If the query's AATags are inconsistent with the cached one, Modified: projects/clang600-import/contrib/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -306,7 +306,9 @@ computeFunctionSummary(ModuleSummaryIndex &Index, cons NonRenamableLocal || HasInlineAsmMaybeReferencingInternal || // Inliner doesn't handle variadic functions. // FIXME: refactor this to use the same code that inliner is using. - F.isVarArg(); + F.isVarArg() || + // Don't try to import functions with noinline attribute. + F.getAttributes().hasFnAttribute(Attribute::NoInline); GlobalValueSummary::GVFlags Flags(F.getLinkage(), NotEligibleForImport, /* Live = */ false, F.isDSOLocal()); FunctionSummary::FFlags FunFlags{ Modified: projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -1268,7 +1268,11 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCE } if (!hasTrunc) return getAddExpr(Operands); - UniqueSCEVs.FindNodeOrInsertPos(ID, IP); // Mutates IP, returns NULL. + // In spite we checked in the beginning that ID is not in the cache, + // it is possible that during recursion and different modification + // ID came to cache, so if we found it, just return it. + if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) + return S; } // trunc(x1*x2*...*xN) --> trunc(x1)*trunc(x2)*...*trunc(xN) if we can @@ -1284,7 +1288,11 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCE } if (!hasTrunc) return getMulExpr(Operands); - UniqueSCEVs.FindNodeOrInsertPos(ID, IP); // Mutates IP, returns NULL. + // In spite we checked in the beginning that ID is not in the cache, + // it is possible that during recursion and different modification + // ID came to cache, so if we found it, just return it. + if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) + return S; } // If the input value is a chrec scev, truncate the chrec's operands. Modified: projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -187,8 +187,21 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOp // generated code. if (isa<DbgInfoIntrinsic>(IP)) ScanLimit++; + + // Conservatively, do not use any instruction which has any of wrap/exact + // flags installed. + // TODO: Instead of simply disable poison instructions we can be clever + // here and match SCEV to this instruction. + auto canGeneratePoison = [](Instruction *I) { + if (isa<OverflowingBinaryOperator>(I) && + (I->hasNoSignedWrap() || I->hasNoUnsignedWrap())) + return true; + if (isa<PossiblyExactOperator>(I) && I->isExact()) + return true; + return false; + }; if (IP->getOpcode() == (unsigned)Opcode && IP->getOperand(0) == LHS && - IP->getOperand(1) == RHS) + IP->getOperand(1) == RHS && !canGeneratePoison(&*IP)) return &*IP; if (IP == BlockBegin) break; } Modified: projects/clang600-import/contrib/llvm/lib/Analysis/TargetTransformInfo.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/TargetTransformInfo.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/TargetTransformInfo.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -314,10 +314,6 @@ int TargetTransformInfo::getIntImmCost(Intrinsic::ID I return Cost; } -bool TargetTransformInfo::isOutOfOrder() const { - return TTIImpl->isOutOfOrder(); -} - unsigned TargetTransformInfo::getNumberOfRegisters(bool Vector) const { return TTIImpl->getNumberOfRegisters(Vector); } Modified: projects/clang600-import/contrib/llvm/lib/Analysis/ValueTracking.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/Analysis/ValueTracking.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/Analysis/ValueTracking.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -4238,14 +4238,14 @@ static SelectPatternResult matchSelectPattern(CmpInst: LHS = CmpLHS; RHS = CmpRHS; - // If the predicate is an "or-equal" (FP) predicate, then signed zeroes may - // return inconsistent results between implementations. - // (0.0 <= -0.0) ? 0.0 : -0.0 // Returns 0.0 - // minNum(0.0, -0.0) // May return -0.0 or 0.0 (IEEE 754-2008 5.3.1) - // Therefore we behave conservatively and only proceed if at least one of the - // operands is known to not be zero, or if we don't care about signed zeroes. + // Signed zero may return inconsistent results between implementations. + // (0.0 <= -0.0) ? 0.0 : -0.0 // Returns 0.0 + // minNum(0.0, -0.0) // May return -0.0 or 0.0 (IEEE 754-2008 5.3.1) + // Therefore, we behave conservatively and only proceed if at least one of the + // operands is known to not be zero or if we don't care about signed zero. switch (Pred) { default: break; + // FIXME: Include OGT/OLT/UGT/ULT. case CmpInst::FCMP_OGE: case CmpInst::FCMP_OLE: case CmpInst::FCMP_UGE: case CmpInst::FCMP_ULE: if (!FMF.noSignedZeros() && !isKnownNonZero(CmpLHS) && @@ -4493,14 +4493,24 @@ SelectPatternResult llvm::matchSelectPattern(Value *V, // Deal with type mismatches. if (CastOp && CmpLHS->getType() != TrueVal->getType()) { - if (Value *C = lookThroughCast(CmpI, TrueVal, FalseVal, CastOp)) + if (Value *C = lookThroughCast(CmpI, TrueVal, FalseVal, CastOp)) { + // If this is a potential fmin/fmax with a cast to integer, then ignore + // -0.0 because there is no corresponding integer value. + if (*CastOp == Instruction::FPToSI || *CastOp == Instruction::FPToUI) + FMF.setNoSignedZeros(); return ::matchSelectPattern(Pred, FMF, CmpLHS, CmpRHS, cast<CastInst>(TrueVal)->getOperand(0), C, LHS, RHS); - if (Value *C = lookThroughCast(CmpI, FalseVal, TrueVal, CastOp)) + } + if (Value *C = lookThroughCast(CmpI, FalseVal, TrueVal, CastOp)) { + // If this is a potential fmin/fmax with a cast to integer, then ignore + // -0.0 because there is no corresponding integer value. + if (*CastOp == Instruction::FPToSI || *CastOp == Instruction::FPToUI) + FMF.setNoSignedZeros(); return ::matchSelectPattern(Pred, FMF, CmpLHS, CmpRHS, C, cast<CastInst>(FalseVal)->getOperand(0), LHS, RHS); + } } return ::matchSelectPattern(Pred, FMF, CmpLHS, CmpRHS, TrueVal, FalseVal, LHS, RHS); Modified: projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -1922,14 +1922,16 @@ SDValue DAGCombiner::foldBinOpIntoSelect(SDNode *BO) { EVT VT = Sel.getValueType(); SDLoc DL(Sel); SDValue NewCT = DAG.getNode(BinOpcode, DL, VT, CT, C1); - assert((NewCT.isUndef() || isConstantOrConstantVector(NewCT) || - isConstantFPBuildVectorOrConstantFP(NewCT)) && - "Failed to constant fold a binop with constant operands"); + if (!NewCT.isUndef() && + !isConstantOrConstantVector(NewCT, true) && + !isConstantFPBuildVectorOrConstantFP(NewCT)) + return SDValue(); SDValue NewCF = DAG.getNode(BinOpcode, DL, VT, CF, C1); - assert((NewCF.isUndef() || isConstantOrConstantVector(NewCF) || - isConstantFPBuildVectorOrConstantFP(NewCF)) && - "Failed to constant fold a binop with constant operands"); + if (!NewCF.isUndef() && + !isConstantOrConstantVector(NewCF, true) && + !isConstantFPBuildVectorOrConstantFP(NewCF)) + return SDValue(); return DAG.getSelect(DL, VT, Sel.getOperand(0), NewCT, NewCF); } @@ -3577,7 +3579,8 @@ SDValue DAGCombiner::foldLogicOfSetCCs(bool IsAnd, SDV // TODO: What is the 'or' equivalent of this fold? // (and (setne X, 0), (setne X, -1)) --> (setuge (add X, 1), 2) - if (IsAnd && LL == RL && CC0 == CC1 && IsInteger && CC0 == ISD::SETNE && + if (IsAnd && LL == RL && CC0 == CC1 && OpVT.getScalarSizeInBits() > 1 && + IsInteger && CC0 == ISD::SETNE && ((isNullConstant(LR) && isAllOnesConstant(RR)) || (isAllOnesConstant(LR) && isNullConstant(RR)))) { SDValue One = DAG.getConstant(1, DL, OpVT); @@ -3641,15 +3644,18 @@ SDValue DAGCombiner::visitANDLike(SDValue N0, SDValue if (N0.getOpcode() == ISD::ADD && N1.getOpcode() == ISD::SRL && VT.getSizeInBits() <= 64) { if (ConstantSDNode *ADDI = dyn_cast<ConstantSDNode>(N0.getOperand(1))) { - APInt ADDC = ADDI->getAPIntValue(); - if (!TLI.isLegalAddImmediate(ADDC.getSExtValue())) { + if (ConstantSDNode *SRLI = dyn_cast<ConstantSDNode>(N1.getOperand(1))) { // Look for (and (add x, c1), (lshr y, c2)). If C1 wasn't a legal // immediate for an add, but it is legal if its top c2 bits are set, // transform the ADD so the immediate doesn't need to be materialized // in a register. - if (ConstantSDNode *SRLI = dyn_cast<ConstantSDNode>(N1.getOperand(1))) { + APInt ADDC = ADDI->getAPIntValue(); + APInt SRLC = SRLI->getAPIntValue(); + if (ADDC.getMinSignedBits() <= 64 && + SRLC.ult(VT.getSizeInBits()) && + !TLI.isLegalAddImmediate(ADDC.getSExtValue())) { APInt Mask = APInt::getHighBitsSet(VT.getSizeInBits(), - SRLI->getZExtValue()); + SRLC.getZExtValue()); if (DAG.MaskedValueIsZero(N0.getOperand(1), Mask)) { ADDC |= Mask; if (TLI.isLegalAddImmediate(ADDC.getSExtValue())) { @@ -3987,6 +3993,12 @@ SDValue DAGCombiner::visitAND(SDNode *N) { // reassociate and if (SDValue RAND = ReassociateOps(ISD::AND, SDLoc(N), N0, N1)) return RAND; + + // Try to convert a constant mask AND into a shuffle clear mask. + if (VT.isVector()) + if (SDValue Shuffle = XformToShuffleWithZero(N)) + return Shuffle; + // fold (and (or x, C), D) -> D if (C & D) == D auto MatchSubset = [](ConstantSDNode *LHS, ConstantSDNode *RHS) { return RHS->getAPIntValue().isSubsetOf(LHS->getAPIntValue()); @@ -16480,6 +16492,8 @@ SDValue DAGCombiner::visitFP16_TO_FP(SDNode *N) { /// e.g. AND V, <0xffffffff, 0, 0xffffffff, 0>. ==> /// vector_shuffle V, Zero, <0, 4, 2, 4> SDValue DAGCombiner::XformToShuffleWithZero(SDNode *N) { + assert(N->getOpcode() == ISD::AND && "Unexpected opcode!"); + EVT VT = N->getValueType(0); SDValue LHS = N->getOperand(0); SDValue RHS = peekThroughBitcast(N->getOperand(1)); @@ -16490,9 +16504,6 @@ SDValue DAGCombiner::XformToShuffleWithZero(SDNode *N) if (LegalOperations) return SDValue(); - if (N->getOpcode() != ISD::AND) - return SDValue(); - if (RHS.getOpcode() != ISD::BUILD_VECTOR) return SDValue(); @@ -16580,10 +16591,6 @@ SDValue DAGCombiner::SimplifyVBinOp(SDNode *N) { if (SDValue Fold = DAG.FoldConstantVectorArithmetic( N->getOpcode(), SDLoc(LHS), LHS.getValueType(), Ops, N->getFlags())) return Fold; - - // Try to convert a constant mask AND into a shuffle clear mask. - if (SDValue Shuffle = XformToShuffleWithZero(N)) - return Shuffle; // Type legalization might introduce new shuffles in the DAG. // Fold (VBinOp (shuffle (A, Undef, Mask)), (shuffle (B, Undef, Mask))) Modified: projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -49,6 +49,8 @@ using namespace llvm; +#define DEBUG_TYPE "legalizevectorops" + namespace { class VectorLegalizer { @@ -226,7 +228,8 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { if (Op.getOpcode() == ISD::LOAD) { LoadSDNode *LD = cast<LoadSDNode>(Op.getNode()); ISD::LoadExtType ExtType = LD->getExtensionType(); - if (LD->getMemoryVT().isVector() && ExtType != ISD::NON_EXTLOAD) + if (LD->getMemoryVT().isVector() && ExtType != ISD::NON_EXTLOAD) { + DEBUG(dbgs() << "\nLegalizing extending vector load: "; Node->dump(&DAG)); switch (TLI.getLoadExtAction(LD->getExtensionType(), LD->getValueType(0), LD->getMemoryVT())) { default: llvm_unreachable("This action is not supported yet!"); @@ -252,11 +255,14 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { Changed = true; return LegalizeOp(ExpandLoad(Op)); } + } } else if (Op.getOpcode() == ISD::STORE) { StoreSDNode *ST = cast<StoreSDNode>(Op.getNode()); EVT StVT = ST->getMemoryVT(); MVT ValVT = ST->getValue().getSimpleValueType(); - if (StVT.isVector() && ST->isTruncatingStore()) + if (StVT.isVector() && ST->isTruncatingStore()) { + DEBUG(dbgs() << "\nLegalizing truncating vector store: "; + Node->dump(&DAG)); switch (TLI.getTruncStoreAction(ValVT, StVT)) { default: llvm_unreachable("This action is not supported yet!"); case TargetLowering::Legal: @@ -270,6 +276,7 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { Changed = true; return LegalizeOp(ExpandStore(Op)); } + } } else if (Op.getOpcode() == ISD::MSCATTER || Op.getOpcode() == ISD::MSTORE) HasVectorValue = true; @@ -376,6 +383,8 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { break; } + DEBUG(dbgs() << "\nLegalizing vector op: "; Node->dump(&DAG)); + switch (TLI.getOperationAction(Node->getOpcode(), QueryType)) { default: llvm_unreachable("This action is not supported yet!"); case TargetLowering::Promote: @@ -383,12 +392,16 @@ SDValue VectorLegalizer::LegalizeOp(SDValue Op) { Changed = true; break; case TargetLowering::Legal: + DEBUG(dbgs() << "Legal node: nothing to do\n"); break; case TargetLowering::Custom: { + DEBUG(dbgs() << "Trying custom legalization\n"); if (SDValue Tmp1 = TLI.LowerOperation(Op, DAG)) { + DEBUG(dbgs() << "Successfully custom legalized node\n"); Result = Tmp1; break; } + DEBUG(dbgs() << "Could not custom legalize node\n"); LLVM_FALLTHROUGH; } case TargetLowering::Expand: Modified: projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -5943,7 +5943,9 @@ SDValue SelectionDAG::getLoad(ISD::MemIndexedMode AM, CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getLoad(EVT VT, const SDLoc &dl, SDValue Chain, @@ -6043,7 +6045,9 @@ SDValue SelectionDAG::getStore(SDValue Chain, const SD CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, @@ -6108,7 +6112,9 @@ SDValue SelectionDAG::getTruncStore(SDValue Chain, con CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getIndexedStore(SDValue OrigStore, const SDLoc &dl, @@ -6134,7 +6140,9 @@ SDValue SelectionDAG::getIndexedStore(SDValue OrigStor CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, @@ -6160,7 +6168,9 @@ SDValue SelectionDAG::getMaskedLoad(EVT VT, const SDLo CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getMaskedStore(SDValue Chain, const SDLoc &dl, @@ -6189,7 +6199,9 @@ SDValue SelectionDAG::getMaskedStore(SDValue Chain, co CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl, @@ -6224,7 +6236,9 @@ SDValue SelectionDAG::getMaskedGather(SDVTList VTs, EV CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl, @@ -6256,7 +6270,9 @@ SDValue SelectionDAG::getMaskedScatter(SDVTList VTs, E CSEMap.InsertNode(N, IP); InsertNode(N); - return SDValue(N, 0); + SDValue V(N, 0); + NewSDValueDbgMsg(V, "Creating new node: ", this); + return V; } SDValue SelectionDAG::getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, @@ -7112,6 +7128,8 @@ void SelectionDAG::transferDbgValues(SDValue From, SDV void SelectionDAG::salvageDebugInfo(SDNode &N) { if (!N.getHasDebugValue()) return; + + SmallVector<SDDbgValue *, 2> ClonedDVs; for (auto DV : GetDbgValues(&N)) { if (DV->isInvalidated()) continue; @@ -7135,13 +7153,16 @@ void SelectionDAG::salvageDebugInfo(SDNode &N) { SDDbgValue *Clone = getDbgValue(DV->getVariable(), DIExpr, N0.getNode(), N0.getResNo(), DV->isIndirect(), DV->getDebugLoc(), DV->getOrder()); + ClonedDVs.push_back(Clone); DV->setIsInvalidated(); - AddDbgValue(Clone, N0.getNode(), false); DEBUG(dbgs() << "SALVAGE: Rewriting"; N0.getNode()->dumprFull(this); dbgs() << " into " << *DIExpr << '\n'); } } } + + for (SDDbgValue *Dbg : ClonedDVs) + AddDbgValue(Dbg, Dbg->getSDNode(), false); } namespace { Modified: projects/clang600-import/contrib/llvm/lib/IR/SafepointIRVerifier.cpp ============================================================================== --- projects/clang600-import/contrib/llvm/lib/IR/SafepointIRVerifier.cpp Fri Dec 29 00:27:12 2017 (r327329) +++ projects/clang600-import/contrib/llvm/lib/IR/SafepointIRVerifier.cpp Fri Dec 29 00:56:15 2017 (r327330) @@ -237,6 +237,59 @@ class InstructionVerifier; /// Builds BasicBlockState for each BB of the function. /// It can traverse function for verification and provides all required /// information. +/// +/// GC pointer may be in one of three states: relocated, unrelocated and +/// poisoned. +/// Relocated pointer may be used without any restrictions. +/// Unrelocated pointer cannot be dereferenced, passed as argument to any call +/// or returned. Unrelocated pointer may be safely compared against another +/// unrelocated pointer or against a pointer exclusively derived from null. +/// Poisoned pointers are produced when we somehow derive pointer from relocated +/// and unrelocated pointers (e.g. phi, select). This pointers may be safely +/// used in a very limited number of situations. Currently the only way to use +/// it is comparison against constant exclusively derived from null. All +/// limitations arise due to their undefined state: this pointers should be +/// treated as relocated and unrelocated simultaneously. +/// Rules of deriving: +/// R + U = P - that's where the poisoned pointers come from +/// P + X = P +/// U + U = U +/// R + R = R +/// X + C = X +/// Where "+" - any operation that somehow derive pointer, U - unrelocated, +/// R - relocated and P - poisoned, C - constant, X - U or R or P or C or +/// nothing (in case when "+" is unary operation). +/// Deriving of pointers by itself is always safe. +/// NOTE: when we are making decision on the status of instruction's result: +/// a) for phi we need to check status of each input *at the end of +/// corresponding predecessor BB*. +/// b) for other instructions we need to check status of each input *at the +/// current point*. +/// +/// FIXME: This works fairly well except one case +/// bb1: +/// p = *some GC-ptr def* +/// p1 = gep p, offset +/// / | +/// / | +/// bb2: | +/// safepoint | +/// \ | +/// \ | +/// bb3: +/// p2 = phi [p, bb2] [p1, bb1] +/// p3 = phi [p, bb2] [p, bb1] +/// here p and p1 is unrelocated +/// p2 and p3 is poisoned (though they shouldn't be) +/// +/// This leads to some weird results: +/// cmp eq p, p2 - illegal instruction (false-positive) +/// cmp eq p1, p2 - illegal instruction (false-positive) +/// cmp eq p, p3 - illegal instruction (false-positive) +/// cmp eq p, p1 - ok +/// To fix this we need to introduce conception of generations and be able to +/// check if two values belong to one generation or not. This way p2 will be +/// considered to be unrelocated and no false alarm will happen. class GCPtrTracker { const Function &F; SpecificBumpPtrAllocator<BasicBlockState> BSAllocator; @@ -244,6 +297,9 @@ class GCPtrTracker { // This set contains defs of unrelocated pointers that are proved to be legal // and don't need verification. DenseSet<const Instruction *> ValidUnrelocatedDefs; + // This set contains poisoned defs. They can be safely ignored during + // verification too. + DenseSet<const Value *> PoisonedDefs; public: GCPtrTracker(const Function &F, const DominatorTree &DT); @@ -251,6 +307,8 @@ class GCPtrTracker { BasicBlockState *getBasicBlockState(const BasicBlock *BB); const BasicBlockState *getBasicBlockState(const BasicBlock *BB) const; + bool isValuePoisoned(const Value *V) const { return PoisonedDefs.count(V); } + /// Traverse each BB of the function and call /// InstructionVerifier::verifyInstruction for each possibly invalid /// instruction. @@ -349,7 +407,9 @@ const BasicBlockState *GCPtrTracker::getBasicBlockStat } bool GCPtrTracker::instructionMayBeSkipped(const Instruction *I) const { - return ValidUnrelocatedDefs.count(I); + // Poisoned defs are skipped since they are always safe by itself by + // definition (for details see comment to this class). + return ValidUnrelocatedDefs.count(I) || PoisonedDefs.count(I); } void GCPtrTracker::verifyFunction(GCPtrTracker &&Tracker, @@ -418,31 +478,78 @@ bool GCPtrTracker::removeValidUnrelocatedDefs(const Ba "Passed Contribution should be from the passed BasicBlockState!"); AvailableValueSet AvailableSet = BBS->AvailableIn; bool ContributionChanged = false; + // For explanation why instructions are processed this way see + // "Rules of deriving" in the comment to this class. for (const Instruction &I : *BB) { - bool ProducesUnrelocatedPointer = false; - if ((isa<GetElementPtrInst>(I) || isa<BitCastInst>(I)) && - containsGCPtrType(I.getType())) { - // GEP/bitcast of unrelocated pointer is legal by itself but this - // def shouldn't appear in any AvailableSet. + bool ValidUnrelocatedPointerDef = false; + bool PoisonedPointerDef = false; + // TODO: `select` instructions should be handled here too. + if (const PHINode *PN = dyn_cast<PHINode>(&I)) { + if (containsGCPtrType(PN->getType())) { + // If both is true, output is poisoned. + bool HasRelocatedInputs = false; + bool HasUnrelocatedInputs = false; + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { + const BasicBlock *InBB = PN->getIncomingBlock(i); + const Value *InValue = PN->getIncomingValue(i); + + if (isNotExclusivelyConstantDerived(InValue)) { + if (isValuePoisoned(InValue)) { + // If any of inputs is poisoned, output is always poisoned too. + HasRelocatedInputs = true; + HasUnrelocatedInputs = true; + break; + } + if (BlockMap[InBB]->AvailableOut.count(InValue)) + HasRelocatedInputs = true; + else + HasUnrelocatedInputs = true; + } + } + if (HasUnrelocatedInputs) { + if (HasRelocatedInputs) + PoisonedPointerDef = true; + else + ValidUnrelocatedPointerDef = true; + } + } + } else if ((isa<GetElementPtrInst>(I) || isa<BitCastInst>(I)) && + containsGCPtrType(I.getType())) { + // GEP/bitcast of unrelocated pointer is legal by itself but this def + // shouldn't appear in any AvailableSet. for (const Value *V : I.operands()) if (containsGCPtrType(V->getType()) && isNotExclusivelyConstantDerived(V) && !AvailableSet.count(V)) { - ProducesUnrelocatedPointer = true; + if (isValuePoisoned(V)) + PoisonedPointerDef = true; + else + ValidUnrelocatedPointerDef = true; break; } } - if (!ProducesUnrelocatedPointer) { - bool Cleared = false; - transferInstruction(I, Cleared, AvailableSet); - (void)Cleared; - } else { - // Remove def of unrelocated pointer from Contribution of this BB - // and trigger update of all its successors. + assert(!(ValidUnrelocatedPointerDef && PoisonedPointerDef) && + "Value cannot be both unrelocated and poisoned!"); + if (ValidUnrelocatedPointerDef) { + // Remove def of unrelocated pointer from Contribution of this BB and + // trigger update of all its successors. Contribution.erase(&I); + PoisonedDefs.erase(&I); ValidUnrelocatedDefs.insert(&I); - DEBUG(dbgs() << "Removing " << I << " from Contribution of " + DEBUG(dbgs() << "Removing urelocated " << I << " from Contribution of " << BB->getName() << "\n"); ContributionChanged = true; + } else if (PoisonedPointerDef) { + // Mark pointer as poisoned, remove its def from Contribution and trigger + // update of all successors. + Contribution.erase(&I); + PoisonedDefs.insert(&I); + DEBUG(dbgs() << "Removing poisoned " << I << " from Contribution of " + << BB->getName() << "\n"); + ContributionChanged = true; + } else { + bool Cleared = false; + transferInstruction(I, Cleared, AvailableSet); + (void)Cleared; } } return ContributionChanged; @@ -524,8 +631,8 @@ void InstructionVerifier::verifyInstruction( // Returns true if LHS and RHS are unrelocated pointers and they are // valid unrelocated uses. - auto hasValidUnrelocatedUse = [&AvailableSet, baseTyLHS, baseTyRHS, &LHS, - &RHS] () { + auto hasValidUnrelocatedUse = [&AvailableSet, Tracker, baseTyLHS, baseTyRHS, + &LHS, &RHS] () { // A cmp instruction has valid unrelocated pointer operands only if // both operands are unrelocated pointers. // In the comparison between two pointers, if one is an unrelocated @@ -545,12 +652,23 @@ void InstructionVerifier::verifyInstruction( (baseTyLHS == BaseType::NonConstant && baseTyRHS == BaseType::ExclusivelySomeConstant)) return false; + + // If one of pointers is poisoned and other is not exclusively derived + // from null it is an invalid expression: it produces poisoned result + // and unless we want to track all defs (not only gc pointers) the only + // option is to prohibit such instructions. + if ((Tracker->isValuePoisoned(LHS) && baseTyRHS != ExclusivelyNull) || + (Tracker->isValuePoisoned(RHS) && baseTyLHS != ExclusivelyNull)) + return false; + // All other cases are valid cases enumerated below: - // 1. Comparison between an exlusively derived null pointer and a + // 1. Comparison between an exclusively derived null pointer and a // constant base pointer. *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712290056.vBT0uFVp013200>