diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index cf42f529c701..610f19ecba26 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -556,6 +556,8 @@ template basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&)) + template class _LIBCPP_TEMPLATE_VIS __basic_string_common { @@ -3999,7 +4001,6 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string) _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_string) -_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+, allocator >(char const*, string const&)) #if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] diff --git a/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h b/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h index 55a23c3cca9b..d6851f7143a5 100644 --- a/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/contrib/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -1220,8 +1220,9 @@ class SelectionDAG { /// If an existing load has uses of its chain, create a token factor node with /// that chain and the new memory node's chain and update users of the old /// chain to the token factor. This ensures that the new memory node will have - /// the same relative memory dependency position as the old load. - void makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New); + /// the same relative memory dependency position as the old load. Returns the + /// new merged load chain. + SDValue makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New); /// Topological-sort the AllNodes list and a /// assign a unique node id for each node in the DAG based on their diff --git a/contrib/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/contrib/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h index 6c951fab6185..b7e462e85d9d 100644 --- a/contrib/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h +++ b/contrib/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h @@ -94,9 +94,9 @@ template class LazyEmittingLayer { llvm_unreachable("Invalid emit-state."); } - void removeModuleFromBaseLayer(BaseLayerT &BaseLayer) { - if (EmitState != NotEmitted) - BaseLayer.removeModule(Handle); + Error removeModuleFromBaseLayer(BaseLayerT& BaseLayer) { + return EmitState != NotEmitted ? BaseLayer.removeModule(Handle) + : Error::success(); } void emitAndFinalize(BaseLayerT &BaseLayer) { @@ -226,9 +226,9 @@ template class LazyEmittingLayer { /// This method will free the memory associated with the given module, both /// in this layer, and the base layer. Error removeModule(ModuleHandleT H) { - (*H)->removeModuleFromBaseLayer(BaseLayer); + Error Err = (*H)->removeModuleFromBaseLayer(BaseLayer); ModuleList.erase(H); - return Error::success(); + return Err; } /// @brief Search for the given named symbol. diff --git a/contrib/llvm/include/llvm/Object/COFFImportFile.h b/contrib/llvm/include/llvm/Object/COFFImportFile.h index 8e215b565fc4..cf9c80a06f49 100644 --- a/contrib/llvm/include/llvm/Object/COFFImportFile.h +++ b/contrib/llvm/include/llvm/Object/COFFImportFile.h @@ -73,6 +73,7 @@ class COFFImportFile : public SymbolicFile { struct COFFShortExport { std::string Name; std::string ExtName; + std::string SymbolName; uint16_t Ordinal = 0; bool Noname = false; @@ -98,7 +99,8 @@ struct COFFShortExport { std::error_code writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef Exports, - COFF::MachineTypes Machine); + COFF::MachineTypes Machine, + bool MakeWeakAliases); } // namespace object } // namespace llvm diff --git a/contrib/llvm/lib/Analysis/ScalarEvolution.cpp b/contrib/llvm/lib/Analysis/ScalarEvolution.cpp index b973203a89b6..9539fd7c7559 100644 --- a/contrib/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/contrib/llvm/lib/Analysis/ScalarEvolution.cpp @@ -162,6 +162,11 @@ static cl::opt cl::desc("Maximum depth of recursive SExt/ZExt"), cl::init(8)); +static cl::opt + MaxAddRecSize("scalar-evolution-max-add-rec-size", cl::Hidden, + cl::desc("Max coefficients in AddRec during evolving"), + cl::init(16)); + //===----------------------------------------------------------------------===// // SCEV class definitions //===----------------------------------------------------------------------===// @@ -2878,6 +2883,12 @@ const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl &Ops, if (!OtherAddRec || OtherAddRec->getLoop() != AddRecLoop) continue; + // Limit max number of arguments to avoid creation of unreasonably big + // SCEVAddRecs with very complex operands. + if (AddRec->getNumOperands() + OtherAddRec->getNumOperands() - 1 > + MaxAddRecSize) + continue; + bool Overflow = false; Type *Ty = AddRec->getType(); bool LargerThan64Bits = getTypeSizeInBits(Ty) > 64; @@ -7582,6 +7593,25 @@ const SCEV *ScalarEvolution::computeSCEVAtScope(const SCEV *V, const Loop *L) { const SCEV *BackedgeTakenCount = getBackedgeTakenCount(LI); if (const SCEVConstant *BTCC = dyn_cast(BackedgeTakenCount)) { + + // This trivial case can show up in some degenerate cases where + // the incoming IR has not yet been fully simplified. + if (BTCC->getValue()->isZero()) { + Value *InitValue = nullptr; + bool MultipleInitValues = false; + for (unsigned i = 0; i < PN->getNumIncomingValues(); i++) { + if (!LI->contains(PN->getIncomingBlock(i))) { + if (!InitValue) + InitValue = PN->getIncomingValue(i); + else if (InitValue != PN->getIncomingValue(i)) { + MultipleInitValues = true; + break; + } + } + if (!MultipleInitValues && InitValue) + return getSCEV(InitValue); + } + } // Okay, we know how many times the containing loop executes. If // this is a constant evolving PHI node, get the final value at // the specified iteration number. diff --git a/contrib/llvm/lib/Analysis/ValueTracking.cpp b/contrib/llvm/lib/Analysis/ValueTracking.cpp index 439b21a81258..cdfe74d158c9 100644 --- a/contrib/llvm/lib/Analysis/ValueTracking.cpp +++ b/contrib/llvm/lib/Analysis/ValueTracking.cpp @@ -4458,6 +4458,10 @@ Optional llvm::isImpliedCondition(const Value *LHS, const Value *RHS, unsigned Depth, AssumptionCache *AC, const Instruction *CxtI, const DominatorTree *DT) { + // Bail out when we hit the limit. + if (Depth == MaxDepth) + return None; + // A mismatch occurs when we compare a scalar cmp to a vector cmp, for example. if (LHS->getType() != RHS->getType()) return None; diff --git a/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index 0cad20db0964..ecb54e1e4b41 100644 --- a/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/contrib/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -302,7 +302,21 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_SCALAR_TO_VECTOR(SDNode *N) { } SDValue DAGTypeLegalizer::ScalarizeVecRes_VSELECT(SDNode *N) { - SDValue Cond = GetScalarizedVector(N->getOperand(0)); + SDValue Cond = N->getOperand(0); + EVT OpVT = Cond.getValueType(); + SDLoc DL(N); + // The vselect result and true/value operands needs scalarizing, but it's + // not a given that the Cond does. For instance, in AVX512 v1i1 is legal. + // See the similar logic in ScalarizeVecRes_VSETCC + if (getTypeAction(OpVT) == TargetLowering::TypeScalarizeVector) { + Cond = GetScalarizedVector(Cond); + } else { + EVT VT = OpVT.getVectorElementType(); + Cond = DAG.getNode( + ISD::EXTRACT_VECTOR_ELT, DL, VT, Cond, + DAG.getConstant(0, DL, TLI.getVectorIdxTy(DAG.getDataLayout()))); + } + SDValue LHS = GetScalarizedVector(N->getOperand(1)); TargetLowering::BooleanContent ScalarBool = TLI.getBooleanContents(false, false); diff --git a/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 823e77850c4b..0ff154784f68 100644 --- a/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -7262,22 +7262,23 @@ void SelectionDAG::TransferDbgValues(SDValue From, SDValue To) { AddDbgValue(I, ToNode, false); } -void SelectionDAG::makeEquivalentMemoryOrdering(LoadSDNode *OldLoad, - SDValue NewMemOp) { +SDValue SelectionDAG::makeEquivalentMemoryOrdering(LoadSDNode *OldLoad, + SDValue NewMemOp) { assert(isa(NewMemOp.getNode()) && "Expected a memop node"); - if (!OldLoad->hasAnyUseOfValue(1)) - return; - // The new memory operation must have the same position as the old load in // terms of memory dependency. Create a TokenFactor for the old load and new // memory operation and update uses of the old load's output chain to use that // TokenFactor. SDValue OldChain = SDValue(OldLoad, 1); SDValue NewChain = SDValue(NewMemOp.getNode(), 1); + if (!OldLoad->hasAnyUseOfValue(1)) + return NewChain; + SDValue TokenFactor = getNode(ISD::TokenFactor, SDLoc(OldLoad), MVT::Other, OldChain, NewChain); ReplaceAllUsesOfValueWith(OldChain, TokenFactor); UpdateNodeOperands(TokenFactor.getNode(), OldChain, NewChain); + return TokenFactor; } //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/lib/CodeGen/VirtRegMap.cpp b/contrib/llvm/lib/CodeGen/VirtRegMap.cpp index 124c2790f68c..f8aacdb8649d 100644 --- a/contrib/llvm/lib/CodeGen/VirtRegMap.cpp +++ b/contrib/llvm/lib/CodeGen/VirtRegMap.cpp @@ -180,6 +180,7 @@ class VirtRegRewriter : public MachineFunctionPass { void addLiveInsForSubRanges(const LiveInterval &LI, unsigned PhysReg) const; void handleIdentityCopy(MachineInstr &MI) const; void expandCopyBundle(MachineInstr &MI) const; + bool subRegLiveThrough(const MachineInstr &MI, unsigned SuperPhysReg) const; public: static char ID; @@ -415,6 +416,32 @@ void VirtRegRewriter::expandCopyBundle(MachineInstr &MI) const { } } +/// Check whether (part of) \p SuperPhysReg is live through \p MI. +/// \pre \p MI defines a subregister of a virtual register that +/// has been assigned to \p SuperPhysReg. +bool VirtRegRewriter::subRegLiveThrough(const MachineInstr &MI, + unsigned SuperPhysReg) const { + SlotIndex MIIndex = LIS->getInstructionIndex(MI); + SlotIndex BeforeMIUses = MIIndex.getBaseIndex(); + SlotIndex AfterMIDefs = MIIndex.getBoundaryIndex(); + for (MCRegUnitIterator Unit(SuperPhysReg, TRI); Unit.isValid(); ++Unit) { + const LiveRange &UnitRange = LIS->getRegUnit(*Unit); + // If the regunit is live both before and after MI, + // we assume it is live through. + // Generally speaking, this is not true, because something like + // "RU = op RU" would match that description. + // However, we know that we are trying to assess whether + // a def of a virtual reg, vreg, is live at the same time of RU. + // If we are in the "RU = op RU" situation, that means that vreg + // is defined at the same time as RU (i.e., "vreg, RU = op RU"). + // Thus, vreg and RU interferes and vreg cannot be assigned to + // SuperPhysReg. Therefore, this situation cannot happen. + if (UnitRange.liveAt(AfterMIDefs) && UnitRange.liveAt(BeforeMIUses)) + return true; + } + return false; +} + void VirtRegRewriter::rewrite() { bool NoSubRegLiveness = !MRI->subRegLivenessEnabled(); SmallVector SuperDeads; @@ -452,7 +479,8 @@ void VirtRegRewriter::rewrite() { // A virtual register kill refers to the whole register, so we may // have to add operands for the super-register. A // partial redef always kills and redefines the super-register. - if (MO.readsReg() && (MO.isDef() || MO.isKill())) + if ((MO.readsReg() && (MO.isDef() || MO.isKill())) || + (MO.isDef() && subRegLiveThrough(*MI, PhysReg))) SuperKills.push_back(PhysReg); if (MO.isDef()) { diff --git a/contrib/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/contrib/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 495e09fbae35..dd3235244e24 100644 --- a/contrib/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/contrib/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -134,13 +134,13 @@ dumpDWARFv5StringOffsetsSection(raw_ostream &OS, StringRef SectionName, uint64_t StringOffset = StrOffsetExt.getRelocatedValue(EntrySize, &Offset); if (Format == DWARF32) { - OS << format("%8.8x ", StringOffset); uint32_t StringOffset32 = (uint32_t)StringOffset; + OS << format("%8.8x ", StringOffset32); const char *S = StrData.getCStr(&StringOffset32); if (S) OS << format("\"%s\"", S); } else - OS << format("%16.16x ", StringOffset); + OS << format("%16.16" PRIx64 " ", StringOffset); OS << "\n"; } } diff --git a/contrib/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/contrib/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp index 6cf44ffa3796..4de46bea301e 100644 --- a/contrib/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/contrib/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -196,7 +196,7 @@ unsigned DWARFVerifier::verifyDebugInfoAttribute(const DWARFDie &Die, ++NumErrors; OS << "error: DW_AT_stmt_list offset is beyond .debug_line " "bounds: " - << format("0x%08" PRIx32, *SectionOffset) << "\n"; + << format("0x%08" PRIx64, *SectionOffset) << "\n"; Die.dump(OS, 0); OS << "\n"; } @@ -234,7 +234,7 @@ unsigned DWARFVerifier::verifyDebugInfoForm(const DWARFDie &Die, if (CUOffset >= CUSize) { ++NumErrors; OS << "error: " << FormEncodingString(Form) << " CU offset " - << format("0x%08" PRIx32, CUOffset) + << format("0x%08" PRIx64, CUOffset) << " is invalid (must be less than CU size of " << format("0x%08" PRIx32, CUSize) << "):\n"; Die.dump(OS, 0); @@ -366,7 +366,7 @@ void DWARFVerifier::verifyDebugLineRows() { if (Row.Address < PrevAddress) { ++NumDebugLineErrors; OS << "error: .debug_line[" - << format("0x%08" PRIx32, + << format("0x%08" PRIx64, *toSectionOffset(Die.find(DW_AT_stmt_list))) << "] row[" << RowIndex << "] decreases in address from previous row:\n"; @@ -381,7 +381,7 @@ void DWARFVerifier::verifyDebugLineRows() { if (Row.File > MaxFileIndex) { ++NumDebugLineErrors; OS << "error: .debug_line[" - << format("0x%08" PRIx32, + << format("0x%08" PRIx64, *toSectionOffset(Die.find(DW_AT_stmt_list))) << "][" << RowIndex << "] has invalid file index " << Row.File << " (valid values are [1," << MaxFileIndex << "]):\n"; diff --git a/contrib/llvm/lib/Object/COFFImportFile.cpp b/contrib/llvm/lib/Object/COFFImportFile.cpp index a515bc8ad16d..ff039463d08c 100644 --- a/contrib/llvm/lib/Object/COFFImportFile.cpp +++ b/contrib/llvm/lib/Object/COFFImportFile.cpp @@ -557,7 +557,7 @@ NewArchiveMember ObjectFactory::createWeakExternal(StringRef Sym, std::error_code writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef Exports, - MachineTypes Machine) { + MachineTypes Machine, bool MakeWeakAliases) { std::vector Members; ObjectFactory OF(llvm::sys::path::filename(ImportName), Machine); @@ -575,7 +575,7 @@ std::error_code writeImportLibrary(StringRef ImportName, StringRef Path, if (E.Private) continue; - if (E.isWeak()) { + if (E.isWeak() && MakeWeakAliases) { Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, false)); Members.push_back(OF.createWeakExternal(E.Name, E.ExtName, true)); continue; @@ -587,7 +587,7 @@ std::error_code writeImportLibrary(StringRef ImportName, StringRef Path, if (E.Constant) ImportType = IMPORT_CONST; - StringRef SymbolName = E.isWeak() ? E.ExtName : E.Name; + StringRef SymbolName = E.SymbolName.empty() ? E.Name : E.SymbolName; ImportNameType NameType = getNameType(SymbolName, E.Name, Machine); Expected Name = E.ExtName.empty() ? SymbolName diff --git a/contrib/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/contrib/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp index 005f2d51e403..9a7f45bde6c9 100644 --- a/contrib/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp +++ b/contrib/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp @@ -388,6 +388,10 @@ static unsigned isMatchingStore(MachineInstr &LoadInst, } static unsigned getPreIndexedOpcode(unsigned Opc) { + // FIXME: We don't currently support creating pre-indexed loads/stores when + // the load or store is the unscaled version. If we decide to perform such an + // optimization in the future the cases for the unscaled loads/stores will + // need to be added here. switch (Opc) { default: llvm_unreachable("Opcode has no pre-indexed equivalent!"); @@ -451,32 +455,42 @@ static unsigned getPostIndexedOpcode(unsigned Opc) { default: llvm_unreachable("Opcode has no post-indexed wise equivalent!"); case AArch64::STRSui: + case AArch64::STURSi: return AArch64::STRSpost; case AArch64::STRDui: + case AArch64::STURDi: return AArch64::STRDpost; case AArch64::STRQui: + case AArch64::STURQi: return AArch64::STRQpost; case AArch64::STRBBui: return AArch64::STRBBpost; case AArch64::STRHHui: return AArch64::STRHHpost; case AArch64::STRWui: + case AArch64::STURWi: return AArch64::STRWpost; case AArch64::STRXui: + case AArch64::STURXi: return AArch64::STRXpost; case AArch64::LDRSui: + case AArch64::LDURSi: return AArch64::LDRSpost; case AArch64::LDRDui: + case AArch64::LDURDi: return AArch64::LDRDpost; case AArch64::LDRQui: + case AArch64::LDURQi: return AArch64::LDRQpost; case AArch64::LDRBBui: return AArch64::LDRBBpost; case AArch64::LDRHHui: return AArch64::LDRHHpost; case AArch64::LDRWui: + case AArch64::LDURWi: return AArch64::LDRWpost; case AArch64::LDRXui: + case AArch64::LDURXi: return AArch64::LDRXpost; case AArch64::LDRSWui: return AArch64::LDRSWpost; @@ -1694,8 +1708,9 @@ bool AArch64LoadStoreOpt::optimizeBlock(MachineBasicBlock &MBB, ++NumPostFolded; break; } - // Don't know how to handle pre/post-index versions, so move to the next - // instruction. + + // Don't know how to handle unscaled pre/post-index versions below, so + // move to the next instruction. if (TII->isUnscaledLdSt(Opc)) { ++MBBI; break; diff --git a/contrib/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp b/contrib/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp index ec49f0d37af4..46d8f0dba691 100644 --- a/contrib/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp +++ b/contrib/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp @@ -769,8 +769,7 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(MachineBasicBlock &MBB, MachineInstr &MI = *MBBI; DebugLoc DL = MI.getDebugLoc(); const MachineOperand &Dest = MI.getOperand(0); - unsigned StatusReg = MI.getOperand(1).getReg(); - bool StatusDead = MI.getOperand(1).isDead(); + unsigned TempReg = MI.getOperand(1).getReg(); // Duplicating undef operands into 2 instructions does not guarantee the same // value on both; However undef should be replaced by xzr anyway. assert(!MI.getOperand(2).isUndef() && "cannot handle undef"); @@ -797,23 +796,9 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(MachineBasicBlock &MBB, } // .Lloadcmp: - // mov wStatus, #0 // ldrex rDest, [rAddr] // cmp rDest, rDesired // bne .Ldone - if (!StatusDead) { - if (IsThumb) { - BuildMI(LoadCmpBB, DL, TII->get(ARM::tMOVi8), StatusReg) - .addDef(ARM::CPSR, RegState::Dead) - .addImm(0) - .add(predOps(ARMCC::AL)); - } else { - BuildMI(LoadCmpBB, DL, TII->get(ARM::MOVi), StatusReg) - .addImm(0) - .add(predOps(ARMCC::AL)) - .add(condCodeOp()); - } - } MachineInstrBuilder MIB; MIB = BuildMI(LoadCmpBB, DL, TII->get(LdrexOp), Dest.getReg()); @@ -836,10 +821,10 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(MachineBasicBlock &MBB, LoadCmpBB->addSuccessor(StoreBB); // .Lstore: - // strex rStatus, rNew, [rAddr] - // cmp rStatus, #0 + // strex rTempReg, rNew, [rAddr] + // cmp rTempReg, #0 // bne .Lloadcmp - MIB = BuildMI(StoreBB, DL, TII->get(StrexOp), StatusReg) + MIB = BuildMI(StoreBB, DL, TII->get(StrexOp), TempReg) .addReg(NewReg) .addReg(AddrReg); if (StrexOp == ARM::t2STREX) @@ -848,7 +833,7 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(MachineBasicBlock &MBB, unsigned CMPri = IsThumb ? ARM::t2CMPri : ARM::CMPri; BuildMI(StoreBB, DL, TII->get(CMPri)) - .addReg(StatusReg, getKillRegState(StatusDead)) + .addReg(TempReg, RegState::Kill) .addImm(0) .add(predOps(ARMCC::AL)); BuildMI(StoreBB, DL, TII->get(Bcc)) @@ -904,8 +889,7 @@ bool ARMExpandPseudo::ExpandCMP_SWAP_64(MachineBasicBlock &MBB, MachineInstr &MI = *MBBI; DebugLoc DL = MI.getDebugLoc(); MachineOperand &Dest = MI.getOperand(0); - unsigned StatusReg = MI.getOperand(1).getReg(); - bool StatusDead = MI.getOperand(1).isDead(); + unsigned TempReg = MI.getOperand(1).getReg(); // Duplicating undef operands into 2 instructions does not guarantee the same // value on both; However undef should be replaced by xzr anyway. assert(!MI.getOperand(2).isUndef() && "cannot handle undef"); @@ -931,7 +915,7 @@ bool ARMExpandPseudo::ExpandCMP_SWAP_64(MachineBasicBlock &MBB, // .Lloadcmp: // ldrexd rDestLo, rDestHi, [rAddr] // cmp rDestLo, rDesiredLo - // sbcs rStatus, rDestHi, rDesiredHi + // sbcs rTempReg, rDestHi, rDesiredHi // bne .Ldone unsigned LDREXD = IsThumb ? ARM::t2LDREXD : ARM::LDREXD; MachineInstrBuilder MIB; @@ -959,17 +943,17 @@ bool ARMExpandPseudo::ExpandCMP_SWAP_64(MachineBasicBlock &MBB, LoadCmpBB->addSuccessor(StoreBB); // .Lstore: - // strexd rStatus, rNewLo, rNewHi, [rAddr] - // cmp rStatus, #0 + // strexd rTempReg, rNewLo, rNewHi, [rAddr] + // cmp rTempReg, #0 // bne .Lloadcmp unsigned STREXD = IsThumb ? ARM::t2STREXD : ARM::STREXD; - MIB = BuildMI(StoreBB, DL, TII->get(STREXD), StatusReg); + MIB = BuildMI(StoreBB, DL, TII->get(STREXD), TempReg); addExclusiveRegPair(MIB, New, 0, IsThumb, TRI); MIB.addReg(AddrReg).add(predOps(ARMCC::AL)); unsigned CMPri = IsThumb ? ARM::t2CMPri : ARM::CMPri; BuildMI(StoreBB, DL, TII->get(CMPri)) - .addReg(StatusReg, getKillRegState(StatusDead)) + .addReg(TempReg, RegState::Kill) .addImm(0) .add(predOps(ARMCC::AL)); BuildMI(StoreBB, DL, TII->get(Bcc)) diff --git a/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td b/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td index d06b7d0896f1..7206083a7079 100644 --- a/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td +++ b/contrib/llvm/lib/Target/ARM/ARMInstrInfo.td @@ -6053,21 +6053,21 @@ def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn), // significantly more naive than the standard expansion: we conservatively // assume seq_cst, strong cmpxchg and omit clrex on failure. -let Constraints = "@earlyclobber $Rd,@earlyclobber $status", +let Constraints = "@earlyclobber $Rd,@earlyclobber $temp", mayLoad = 1, mayStore = 1 in { -def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$status), +def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp), (ins GPR:$addr, GPR:$desired, GPR:$new), NoItinerary, []>, Sched<[]>; -def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$status), +def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp), (ins GPR:$addr, GPR:$desired, GPR:$new), NoItinerary, []>, Sched<[]>; -def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$status), +def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp), (ins GPR:$addr, GPR:$desired, GPR:$new), NoItinerary, []>, Sched<[]>; -def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$status), +def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp), (ins GPR:$addr, GPRPair:$desired, GPRPair:$new), NoItinerary, []>, Sched<[]>; } diff --git a/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp b/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp index 7563bffd8f87..1e73122cdc38 100644 --- a/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -419,6 +419,11 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setOperationAction(ISD::SELECT, VT, Custom); setOperationAction(ISD::SETCC, VT, Custom); } + + // Custom action for SELECT MMX and expand action for SELECT_CC MMX + setOperationAction(ISD::SELECT, MVT::x86mmx, Custom); + setOperationAction(ISD::SELECT_CC, MVT::x86mmx, Expand); + setOperationAction(ISD::EH_RETURN , MVT::Other, Custom); // NOTE: EH_SJLJ_SETJMP/_LONGJMP supported here is NOT intended to support // SjLj exception handling but a light-weight setjmp/longjmp replacement to @@ -1383,7 +1388,7 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, // (result) is 256-bit but the source is 512-bit wide. // 128-bit was made Custom under AVX1. for (auto VT : { MVT::v32i8, MVT::v16i16, MVT::v8i32, MVT::v4i64, - MVT::v8f32, MVT::v4f64 }) + MVT::v8f32, MVT::v4f64, MVT::v1i1 }) setOperationAction(ISD::EXTRACT_SUBVECTOR, VT, Custom); for (auto VT : { MVT::v2i1, MVT::v4i1, MVT::v8i1, MVT::v16i1, MVT::v32i1, MVT::v64i1 }) @@ -14570,6 +14575,21 @@ static SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, const X86Subtarget &Subtarget, unsigned IdxVal = cast(Idx)->getZExtValue(); MVT ResVT = Op.getSimpleValueType(); + // When v1i1 is legal a scalarization of a vselect with a vXi1 Cond + // would result with: v1i1 = extract_subvector(vXi1, idx). + // Lower these into extract_vector_elt which is already selectable. + if (ResVT == MVT::v1i1) { + assert(Subtarget.hasAVX512() && + "Boolean EXTRACT_SUBVECTOR requires AVX512"); + + MVT EltVT = ResVT.getVectorElementType(); + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + MVT LegalVT = + (TLI.getTypeToTransformTo(*DAG.getContext(), EltVT)).getSimpleVT(); + SDValue Res = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, LegalVT, In, Idx); + return DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, ResVT, Res); + } + assert((In.getSimpleValueType().is256BitVector() || In.getSimpleValueType().is512BitVector()) && "Can only extract from 256-bit or 512-bit vectors"); @@ -20651,8 +20671,8 @@ static SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, const X86Subtarget &Subtarget, } // ADC/ADCX/SBB case ADX: { - SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::Other); - SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::Other); + SDVTList CFVTs = DAG.getVTList(Op->getValueType(0), MVT::i32); + SDVTList VTs = DAG.getVTList(Op.getOperand(3)->getValueType(0), MVT::i32); SDValue GenCF = DAG.getNode(X86ISD::ADD, dl, CFVTs, Op.getOperand(2), DAG.getConstant(-1, dl, MVT::i8)); SDValue Res = DAG.getNode(IntrData->Opc0, dl, VTs, Op.getOperand(3), @@ -30663,6 +30683,14 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &DAG, return SDValue(N, 0); } + // Custom action for SELECT MMX + if (VT == MVT::x86mmx) { + LHS = DAG.getBitcast(MVT::i64, LHS); + RHS = DAG.getBitcast(MVT::i64, RHS); + SDValue newSelect = DAG.getNode(ISD::SELECT, DL, MVT::i64, Cond, LHS, RHS); + return DAG.getBitcast(VT, newSelect); + } + return SDValue(); } @@ -33358,7 +33386,8 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, SDValue NewLd = DAG.getLoad(LdVT, LdDL, Ld->getChain(), Ld->getBasePtr(), Ld->getPointerInfo(), Ld->getAlignment(), Ld->getMemOperand()->getFlags()); - SDValue NewChain = NewLd.getValue(1); + // Make sure new load is placed in same chain order. + SDValue NewChain = DAG.makeEquivalentMemoryOrdering(Ld, NewLd); if (TokenFactorIndex >= 0) { Ops.push_back(NewChain); NewChain = DAG.getNode(ISD::TokenFactor, LdDL, MVT::Other, Ops); @@ -33379,11 +33408,12 @@ static SDValue combineStore(SDNode *N, SelectionDAG &DAG, Ld->getPointerInfo().getWithOffset(4), MinAlign(Ld->getAlignment(), 4), Ld->getMemOperand()->getFlags()); + // Make sure new loads are placed in same chain order. + SDValue NewChain = DAG.makeEquivalentMemoryOrdering(Ld, LoLd); + NewChain = DAG.makeEquivalentMemoryOrdering(Ld, HiLd); - SDValue NewChain = LoLd.getValue(1); if (TokenFactorIndex >= 0) { - Ops.push_back(LoLd); - Ops.push_back(HiLd); + Ops.push_back(NewChain); NewChain = DAG.getNode(ISD::TokenFactor, LdDL, MVT::Other, Ops); } diff --git a/contrib/llvm/lib/Target/X86/X86InstrAVX512.td b/contrib/llvm/lib/Target/X86/X86InstrAVX512.td index 705d0f7a5cf7..0e654a380e7c 100644 --- a/contrib/llvm/lib/Target/X86/X86InstrAVX512.td +++ b/contrib/llvm/lib/Target/X86/X86InstrAVX512.td @@ -978,6 +978,44 @@ multiclass avx512_int_broadcast_reg opc, X86VectorVTInfo _, (_.VT (OpNode SrcRC:$src))>, T8PD, EVEX; } +multiclass avx512_int_broadcastbw_reg opc, string Name, + X86VectorVTInfo _, SDPatternOperator OpNode, + RegisterClass SrcRC, SubRegIndex Subreg> { + let ExeDomain = _.ExeDomain in + defm r : AVX512_maskable_custom, T8PD, EVEX; + + def : Pat <(_.VT (OpNode SrcRC:$src)), + (!cast(Name#r) + (i32 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), SrcRC:$src, Subreg)))>; + + def : Pat <(vselect _.KRCWM:$mask, (_.VT (OpNode SrcRC:$src)), _.RC:$src0), + (!cast(Name#rk) _.RC:$src0, _.KRCWM:$mask, + (i32 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), SrcRC:$src, Subreg)))>; + + def : Pat <(vselect _.KRCWM:$mask, (_.VT (OpNode SrcRC:$src)), _.ImmAllZerosV), + (!cast(Name#rkz) _.KRCWM:$mask, + (i32 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), SrcRC:$src, Subreg)))>; +} + +multiclass avx512_int_broadcastbw_reg_vl opc, string Name, + AVX512VLVectorVTInfo _, SDPatternOperator OpNode, + RegisterClass SrcRC, SubRegIndex Subreg, Predicate prd> { + let Predicates = [prd] in + defm Z : avx512_int_broadcastbw_reg, EVEX_V512; + let Predicates = [prd, HasVLX] in { + defm Z256 : avx512_int_broadcastbw_reg, EVEX_V256; + defm Z128 : avx512_int_broadcastbw_reg, EVEX_V128; + } +} + multiclass avx512_int_broadcast_reg_vl opc, AVX512VLVectorVTInfo _, SDPatternOperator OpNode, RegisterClass SrcRC, Predicate prd> { @@ -989,18 +1027,11 @@ multiclass avx512_int_broadcast_reg_vl opc, AVX512VLVectorVTInfo _, } } -let isCodeGenOnly = 1 in { -defm VPBROADCASTBr : avx512_int_broadcast_reg_vl<0x7A, avx512vl_i8_info, - X86VBroadcast, GR8, HasBWI>; -defm VPBROADCASTWr : avx512_int_broadcast_reg_vl<0x7B, avx512vl_i16_info, - X86VBroadcast, GR16, HasBWI>; -} -let isAsmParserOnly = 1 in { - defm VPBROADCASTBr_Alt : avx512_int_broadcast_reg_vl<0x7A, avx512vl_i8_info, - null_frag, GR32, HasBWI>; - defm VPBROADCASTWr_Alt : avx512_int_broadcast_reg_vl<0x7B, avx512vl_i16_info, - null_frag, GR32, HasBWI>; -} +defm VPBROADCASTBr : avx512_int_broadcastbw_reg_vl<0x7A, "VPBROADCASTBr", + avx512vl_i8_info, X86VBroadcast, GR8, sub_8bit, HasBWI>; +defm VPBROADCASTWr : avx512_int_broadcastbw_reg_vl<0x7B, "VPBROADCASTWr", + avx512vl_i16_info, X86VBroadcast, GR16, sub_16bit, + HasBWI>; defm VPBROADCASTDr : avx512_int_broadcast_reg_vl<0x7C, avx512vl_i32_info, X86VBroadcast, GR32, HasAVX512>; defm VPBROADCASTQr : avx512_int_broadcast_reg_vl<0x7C, avx512vl_i64_info, diff --git a/contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp b/contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp index a7de79306074..fc15dc1e6032 100644 --- a/contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp +++ b/contrib/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp @@ -60,11 +60,13 @@ std::vector> OwningMBs; // Opens a file. Path has to be resolved already. // Newly created memory buffers are owned by this driver. -MemoryBufferRef openFile(StringRef Path) { +Optional openFile(StringRef Path) { ErrorOr> MB = MemoryBuffer::getFile(Path); - if (std::error_code EC = MB.getError()) + if (std::error_code EC = MB.getError()) { llvm::errs() << "fail openFile: " << EC.message() << "\n"; + return None; + } MemoryBufferRef MBRef = MB.get()->getMemBufferRef(); OwningMBs.push_back(std::move(MB.get())); // take ownership @@ -114,11 +116,16 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef ArgsArr) { for (auto *Arg : Args.filtered(OPT_UNKNOWN)) llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n"; - MemoryBufferRef MB; - if (auto *Arg = Args.getLastArg(OPT_d)) - MB = openFile(Arg->getValue()); + if (!Args.hasArg(OPT_d)) { + llvm::errs() << "no definition file specified\n"; + return 1; + } - if (!MB.getBufferSize()) { + Optional MB = openFile(Args.getLastArg(OPT_d)->getValue()); + if (!MB) + return 1; + + if (!MB->getBufferSize()) { llvm::errs() << "definition file empty\n"; return 1; } @@ -133,7 +140,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef ArgsArr) { } Expected Def = - parseCOFFModuleDefinition(MB, Machine, true); + parseCOFFModuleDefinition(*MB, Machine, true); if (!Def) { llvm::errs() << "error parsing definition\n" @@ -154,7 +161,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayRef ArgsArr) { if (Path.empty()) Path = getImplibPath(Def->OutputFile); - if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine)) + if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true)) return 1; return 0; } diff --git a/contrib/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/contrib/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index a33490f6e4ac..ddc975cbed1a 100644 --- a/contrib/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/contrib/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -1470,6 +1470,7 @@ void DFSanVisitor::visitCallSite(CallSite CS) { } i = CS.arg_begin(); + const unsigned ShadowArgStart = Args.size(); for (unsigned n = FT->getNumParams(); n != 0; ++i, --n) Args.push_back(DFSF.getShadow(*i)); @@ -1505,6 +1506,15 @@ void DFSanVisitor::visitCallSite(CallSite CS) { CustomCI->setCallingConv(CI->getCallingConv()); CustomCI->setAttributes(CI->getAttributes()); + // Update the parameter attributes of the custom call instruction to + // zero extend the shadow parameters. This is required for targets + // which consider ShadowTy an illegal type. + for (unsigned n = 0; n < FT->getNumParams(); n++) { + const unsigned ArgNo = ShadowArgStart + n; + if (CustomCI->getArgOperand(ArgNo)->getType() == DFSF.DFS.ShadowTy) + CustomCI->addParamAttr(ArgNo, Attribute::ZExt); + } + if (!FT->getReturnType()->isVoidTy()) { LoadInst *LabelLoad = IRB.CreateLoad(DFSF.LabelReturnAlloca); DFSF.setShadow(CustomCI, LabelLoad); diff --git a/contrib/llvm/lib/Transforms/Scalar/BDCE.cpp b/contrib/llvm/lib/Transforms/Scalar/BDCE.cpp index 61e8700f1cd6..2e5618686ec2 100644 --- a/contrib/llvm/lib/Transforms/Scalar/BDCE.cpp +++ b/contrib/llvm/lib/Transforms/Scalar/BDCE.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/BDCE.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/DemandedBits.h" @@ -35,6 +36,46 @@ using namespace llvm; STATISTIC(NumRemoved, "Number of instructions removed (unused)"); STATISTIC(NumSimplified, "Number of instructions trivialized (dead bits)"); +/// If an instruction is trivialized (dead), then the chain of users of that +/// instruction may need to be cleared of assumptions that can no longer be +/// guaranteed correct. +static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) { + assert(I->getType()->isIntegerTy() && "Trivializing a non-integer value?"); + + // Initialize the worklist with eligible direct users. + SmallVector WorkList; + for (User *JU : I->users()) { + // If all bits of a user are demanded, then we know that nothing below that + // in the def-use chain needs to be changed. + auto *J = dyn_cast(JU); + if (J && !DB.getDemandedBits(J).isAllOnesValue()) + WorkList.push_back(J); + } + + // DFS through subsequent users while tracking visits to avoid cycles. + SmallPtrSet Visited; + while (!WorkList.empty()) { + Instruction *J = WorkList.pop_back_val(); + + // NSW, NUW, and exact are based on operands that might have changed. + J->dropPoisonGeneratingFlags(); + + // We do not have to worry about llvm.assume or range metadata: + // 1. llvm.assume demands its operand, so trivializing can't change it. + // 2. range metadata only applies to memory accesses which demand all bits. + + Visited.insert(J); + + for (User *KU : J->users()) { + // If all bits of a user are demanded, then we know that nothing below + // that in the def-use chain needs to be changed. + auto *K = dyn_cast(KU); + if (K && !Visited.count(K) && !DB.getDemandedBits(K).isAllOnesValue()) + WorkList.push_back(K); + } + } +} + static bool bitTrackingDCE(Function &F, DemandedBits &DB) { SmallVector Worklist; bool Changed = false; @@ -51,6 +92,9 @@ static bool bitTrackingDCE(Function &F, DemandedBits &DB) { // replacing all uses with something else. Then, if they don't need to // remain live (because they have side effects, etc.) we can remove them. DEBUG(dbgs() << "BDCE: Trivializing: " << I << " (all bits dead)\n"); + + clearAssumptionsOfUsers(&I, DB); + // FIXME: In theory we could substitute undef here instead of zero. // This should be reconsidered once we settle on the semantics of // undef, poison, etc. diff --git a/contrib/llvm/tools/clang/include/clang-c/Index.h b/contrib/llvm/tools/clang/include/clang-c/Index.h index b35f436e91b6..3b5ea9fa539b 100644 --- a/contrib/llvm/tools/clang/include/clang-c/Index.h +++ b/contrib/llvm/tools/clang/include/clang-c/Index.h @@ -3206,6 +3206,8 @@ enum CXCallingConv { CXCallingConv_X86RegCall = 8, CXCallingConv_IntelOclBicc = 9, CXCallingConv_Win64 = 10, + /* Alias for compatibility with older versions of API. */ + CXCallingConv_X86_64Win64 = CXCallingConv_Win64, CXCallingConv_X86_64SysV = 11, CXCallingConv_X86VectorCall = 12, CXCallingConv_Swift = 13, diff --git a/contrib/llvm/tools/clang/include/clang/AST/Decl.h b/contrib/llvm/tools/clang/include/clang/AST/Decl.h index 08b34a75aa60..54e6ebcd8af2 100644 --- a/contrib/llvm/tools/clang/include/clang/AST/Decl.h +++ b/contrib/llvm/tools/clang/include/clang/AST/Decl.h @@ -1666,8 +1666,7 @@ class FunctionDecl : public DeclaratorDecl, public DeclContext, unsigned HasSkippedBody : 1; /// Indicates if the function declaration will have a body, once we're done - /// parsing it. (We don't set it to false when we're done parsing, in the - /// hopes this is simpler.) + /// parsing it. unsigned WillHaveBody : 1; /// \brief End part of this FunctionDecl's source range. diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticDriverKinds.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticDriverKinds.td index a28d63182749..fcef881fa0ae 100644 --- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -138,9 +138,10 @@ def err_drv_cc_print_options_failure : Error< def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">; def err_drv_preamble_format : Error< "incorrect format for -preamble-bytes=N,END">; -def err_invalid_ios_deployment_target : Error< +def warn_invalid_ios_deployment_target : Warning< "invalid iOS deployment version '%0', iOS 10 is the maximum deployment " - "target for 32-bit targets">; + "target for 32-bit targets">, InGroup, + DefaultError; def err_drv_conflicting_deployment_targets : Error< "conflicting deployment targets, both '%0' and '%1' are present in environment">; def err_arc_unsupported_on_runtime : Error< diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td index 53d8f36ecd00..23e4d4633ae2 100644 --- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td +++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td @@ -151,9 +151,13 @@ def GNUFlexibleArrayUnionMember : DiagGroup<"gnu-flexible-array-union-member">; def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">; def FormatExtraArgs : DiagGroup<"format-extra-args">; def FormatZeroLength : DiagGroup<"format-zero-length">; -def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">; + +def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">; + +def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">; +def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; // Name of this warning in GCC. -def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>; +def NoexceptType : DiagGroup<"noexcept-type", [CXX17CompatMangling]>; // Warnings for C++1y code which is not compatible with prior C++ standards. def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">; @@ -215,9 +219,10 @@ def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat]>; def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic", [CXXPre1zCompatPedantic]>; -def CXX1zCompat : DiagGroup<"c++1z-compat", [DeprecatedRegister, +def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister, DeprecatedIncrementBool, - CXX1zCompatMangling]>; + CXX17CompatMangling]>; +def : DiagGroup<"c++1z-compat", [CXX17Compat]>; def ExitTimeDestructors : DiagGroup<"exit-time-destructors">; def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">; @@ -769,10 +774,11 @@ def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>; // A warning group for warnings about using C++1z features as extensions in // earlier C++ versions. -def CXX1z : DiagGroup<"c++1z-extensions">; +def CXX17 : DiagGroup<"c++17-extensions">; def : DiagGroup<"c++0x-extensions", [CXX11]>; def : DiagGroup<"c++1y-extensions", [CXX14]>; +def : DiagGroup<"c++1z-extensions", [CXX17]>; def DelegatingCtorCycles : DiagGroup<"delegating-ctor-cycles">; diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticLexKinds.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticLexKinds.td index d6de5c04a74d..706881bfdc5d 100644 --- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticLexKinds.td +++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticLexKinds.td @@ -181,10 +181,10 @@ def err_hex_constant_requires : Error< def ext_hex_constant_invalid : Extension< "hexadecimal floating constants are a C99 feature">, InGroup; def ext_hex_literal_invalid : Extension< - "hexadecimal floating literals are a C++1z feature">, InGroup; + "hexadecimal floating literals are a C++17 feature">, InGroup; def warn_cxx1z_hex_literal : Warning< "hexadecimal floating literals are incompatible with " - "C++ standards before C++1z">, + "C++ standards before C++17">, InGroup, DefaultIgnore; def ext_binary_literal : Extension< "binary integer literals are a GNU extension">, InGroup; @@ -208,7 +208,7 @@ def warn_cxx98_compat_unicode_literal : Warning< "unicode literals are incompatible with C++98">, InGroup, DefaultIgnore; def warn_cxx14_compat_u8_character_literal : Warning< - "unicode literals are incompatible with C++ standards before C++1z">, + "unicode literals are incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def warn_cxx11_compat_user_defined_literal : Warning< "identifier after literal will be treated as a user-defined literal suffix " diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td index f39ffeae61f4..5170c07bf666 100644 --- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -211,10 +211,10 @@ def err_inline_namespace_alias : Error<"namespace alias cannot be inline">; def err_namespace_nonnamespace_scope : Error< "namespaces can only be defined in global or namespace scope">; def ext_nested_namespace_definition : ExtWarn< - "nested namespace definition is a C++1z extension; " - "define each namespace separately">, InGroup; + "nested namespace definition is a C++17 extension; " + "define each namespace separately">, InGroup; def warn_cxx14_compat_nested_namespace_definition : Warning< - "nested namespace definition is incompatible with C++ standards before C++1z">, + "nested namespace definition is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def err_inline_nested_namespace_definition : Error< "nested namespace definition cannot be 'inline'">; @@ -358,7 +358,7 @@ def err_expected_coloncolon_after_super : Error< "expected '::' after '__super'">; def ext_decomp_decl_empty : ExtWarn< - "ISO C++1z does not allow a decomposition group to be empty">, + "ISO C++17 does not allow a decomposition group to be empty">, InGroup>; /// Objective-C parser diagnostics @@ -522,16 +522,16 @@ def err_function_is_not_record : Error< def err_super_in_using_declaration : Error< "'__super' cannot be used with a using declaration">; def ext_constexpr_if : ExtWarn< - "constexpr if is a C++1z extension">, InGroup; + "constexpr if is a C++17 extension">, InGroup; def warn_cxx14_compat_constexpr_if : Warning< - "constexpr if is incompatible with C++ standards before C++1z">, + "constexpr if is incompatible with C++ standards before C++17">, DefaultIgnore, InGroup; def ext_init_statement : ExtWarn< - "'%select{if|switch}0' initialization statements are a C++1z extension">, - InGroup; + "'%select{if|switch}0' initialization statements are a C++17 extension">, + InGroup; def warn_cxx14_compat_init_statement : Warning< "%select{if|switch}0 initialization statements are incompatible with " - "C++ standards before C++1z">, DefaultIgnore, InGroup; + "C++ standards before C++17">, DefaultIgnore, InGroup; // C++ derived classes def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">; @@ -560,7 +560,7 @@ def warn_cxx98_compat_nullptr : Warning< def warn_cxx14_compat_attribute : Warning< "attributes on %select{a namespace|an enumerator}0 declaration are " - "incompatible with C++ standards before C++1z">, + "incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def warn_cxx98_compat_alignas : Warning<"'alignas' is incompatible with C++98">, InGroup, DefaultIgnore; @@ -577,10 +577,10 @@ def err_cxx11_attribute_repeated : Error< "attribute %0 cannot appear multiple times in an attribute specifier">; def warn_cxx14_compat_using_attribute_ns : Warning< "default scope specifier for attributes is incompatible with C++ standards " - "before C++1z">, InGroup, DefaultIgnore; + "before C++17">, InGroup, DefaultIgnore; def ext_using_attribute_ns : ExtWarn< - "default scope specifier for attributes is a C++1z extension">, - InGroup; + "default scope specifier for attributes is a C++17 extension">, + InGroup; def err_using_attribute_ns_conflict : Error< "attribute with scope specifier cannot follow default scope specifier">; def err_attributes_not_allowed : Error<"an attribute list cannot appear here">; @@ -617,11 +617,11 @@ def err_expected_comma_greater : Error< def err_class_on_template_template_param : Error< "template template parameter requires 'class' after the parameter list">; def ext_template_template_param_typename : ExtWarn< - "template template parameter using 'typename' is a C++1z extension">, - InGroup; + "template template parameter using 'typename' is a C++17 extension">, + InGroup; def warn_cxx14_compat_template_template_param_typename : Warning< "template template parameter using 'typename' is " - "incompatible with C++ standards before C++1z">, + "incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def err_template_spec_syntax_non_template : Error< "identifier followed by '<' indicates a class template specialization but " @@ -695,10 +695,10 @@ def err_default_template_template_parameter_not_template : Error< "template">; def ext_fold_expression : ExtWarn< - "pack fold expression is a C++1z extension">, - InGroup; + "pack fold expression is a C++17 extension">, + InGroup; def warn_cxx14_compat_fold_expression : Warning< - "pack fold expression is incompatible with C++ standards before C++1z">, + "pack fold expression is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def err_expected_fold_operator : Error< "expected a foldable binary operator in fold expression">; @@ -751,16 +751,16 @@ def err_alias_declaration_pack_expansion : Error< // C++1z using-declaration pack expansions def ext_multi_using_declaration : ExtWarn< "use of multiple declarators in a single using declaration is " - "a C++1z extension">, InGroup; + "a C++17 extension">, InGroup; def warn_cxx1z_compat_multi_using_declaration : Warning< "use of multiple declarators in a single using declaration is " - "incompatible with C++ standards before C++1z">, + "incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def ext_using_declaration_pack : ExtWarn< - "pack expansion of using declaration is a C++1z extension">, InGroup; + "pack expansion of using declaration is a C++17 extension">, InGroup; def warn_cxx1z_compat_using_declaration_pack : Warning< "pack expansion using declaration is incompatible with C++ standards " - "before C++1z">, InGroup, DefaultIgnore; + "before C++17">, InGroup, DefaultIgnore; // C++11 override control def ext_override_control_keyword : ExtWarn< @@ -817,10 +817,10 @@ def err_expected_star_this_capture : Error< // C++1z constexpr lambda expressions def warn_cxx14_compat_constexpr_on_lambda : Warning< - "constexpr on lambda expressions is incompatible with C++ standards before C++1z">, + "constexpr on lambda expressions is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def ext_constexpr_on_lambda_cxx1z : ExtWarn< - "'constexpr' on lambda expressions is a C++1z extension">, InGroup; + "'constexpr' on lambda expressions is a C++17 extension">, InGroup; // Availability attribute def err_expected_version : Error< diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td index af14638e1d61..6456913a1549 100644 --- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -211,9 +211,9 @@ def warn_auto_storage_class : Warning< def warn_deprecated_register : Warning< "'register' storage class specifier is deprecated " - "and incompatible with C++1z">, InGroup; + "and incompatible with C++17">, InGroup; def ext_register_storage_class : ExtWarn< - "ISO C++1z does not allow 'register' storage class specifier">, + "ISO C++17 does not allow 'register' storage class specifier">, DefaultError, InGroup; def err_invalid_decl_spec_combination : Error< @@ -391,9 +391,9 @@ def err_decomp_decl_context : Error< "decomposition declaration not permitted in this context">; def warn_cxx14_compat_decomp_decl : Warning< "decomposition declarations are incompatible with " - "C++ standards before C++1z">, DefaultIgnore, InGroup; + "C++ standards before C++17">, DefaultIgnore, InGroup; def ext_decomp_decl : ExtWarn< - "decomposition declarations are a C++1z extension">, InGroup; + "decomposition declarations are a C++17 extension">, InGroup; def err_decomp_decl_spec : Error< "decomposition declaration cannot be declared " "%plural{1:'%1'|:with '%1' specifiers}0">; @@ -494,7 +494,7 @@ def err_access_decl : Error< "ISO C++11 does not allow access declarations; " "use using declarations instead">; def ext_dynamic_exception_spec : ExtWarn< - "ISO C++1z does not allow dynamic exception specifications">, + "ISO C++17 does not allow dynamic exception specifications">, InGroup, DefaultError; def warn_exception_spec_deprecated : Warning< "dynamic exception specifications are deprecated">, @@ -507,7 +507,7 @@ def warn_deprecated_copy_operation : Warning< InGroup, DefaultIgnore; def warn_cxx1z_compat_exception_spec_in_signature : Warning< "mangled name of %0 will change in C++17 due to non-throwing exception " - "specification in function signature">, InGroup; + "specification in function signature">, InGroup; def warn_global_constructor : Warning< "declaration requires a global constructor">, @@ -1200,15 +1200,15 @@ def err_static_assert_expression_is_not_constant : Error< "static_assert expression is not an integral constant expression">; def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">; def ext_static_assert_no_message : ExtWarn< - "static_assert with no message is a C++1z extension">, InGroup; + "static_assert with no message is a C++17 extension">, InGroup; def warn_cxx14_compat_static_assert_no_message : Warning< - "static_assert with no message is incompatible with C++ standards before C++1z">, + "static_assert with no message is incompatible with C++ standards before C++17">, DefaultIgnore, InGroup; def ext_inline_variable : ExtWarn< - "inline variables are a C++1z extension">, InGroup; + "inline variables are a C++17 extension">, InGroup; def warn_cxx14_compat_inline_variable : Warning< - "inline variables are incompatible with C++ standards before C++1z">, + "inline variables are incompatible with C++ standards before C++17">, DefaultIgnore, InGroup; def warn_inline_namespace_reopened_noninline : Warning< @@ -1922,7 +1922,7 @@ def err_auto_not_allowed : Error< "|in non-static struct member|in struct member" "|in non-static union member|in union member" "|in non-static class member|in interface member" - "|in exception declaration|in template parameter until C++1z|in block literal" + "|in exception declaration|in template parameter until C++17|in block literal" "|in template argument|in typedef|in type alias|in function return type" "|in conversion function type|here|in lambda parameter" "|in type allocated by 'new'|in K&R-style function parameter" @@ -2147,11 +2147,11 @@ def err_for_range_iter_deduction_failure : Error< def err_for_range_member_begin_end_mismatch : Error< "range type %0 has '%select{begin|end}1' member but no '%select{end|begin}1' member">; def ext_for_range_begin_end_types_differ : ExtWarn< - "'begin' and 'end' returning different types (%0 and %1) is a C++1z extension">, - InGroup; + "'begin' and 'end' returning different types (%0 and %1) is a C++17 extension">, + InGroup; def warn_for_range_begin_end_types_differ : Warning< "'begin' and 'end' returning different types (%0 and %1) is incompatible " - "with C++ standards before C++1z">, InGroup, DefaultIgnore; + "with C++ standards before C++17">, InGroup, DefaultIgnore; def note_in_for_range: Note< "when looking up '%select{begin|end}0' function for range expression " "of type %1">; @@ -3905,7 +3905,7 @@ def err_template_nontype_parm_bad_type : Error< "a non-type template parameter cannot have type %0">; def warn_cxx14_compat_template_nontype_parm_auto_type : Warning< "non-type template parameters declared with %0 are incompatible with C++ " - "standards before C++1z">, + "standards before C++17">, DefaultIgnore, InGroup; def err_template_param_default_arg_redefinition : Error< "template parameter redefines default argument">; @@ -6337,9 +6337,9 @@ def note_member_first_declared_here : Note< def err_decrement_bool : Error<"cannot decrement expression of type bool">; def warn_increment_bool : Warning< "incrementing expression of type bool is deprecated and " - "incompatible with C++1z">, InGroup; + "incompatible with C++17">, InGroup; def ext_increment_bool : ExtWarn< - "ISO C++1z does not allow incrementing expression of type bool">, + "ISO C++17 does not allow incrementing expression of type bool">, DefaultError, InGroup; def err_increment_decrement_enum : Error< "cannot %select{decrement|increment}0 expression of enum type %1">; @@ -6528,10 +6528,10 @@ let CategoryName = "Lambda Issue" in { // C++1z '*this' captures. def warn_cxx14_compat_star_this_lambda_capture : Warning< - "by value capture of '*this' is incompatible with C++ standards before C++1z">, + "by value capture of '*this' is incompatible with C++ standards before C++17">, InGroup, DefaultIgnore; def ext_star_this_lambda_capture_cxx1z : ExtWarn< - "capture of '*this' by copy is a C++1z extension">, InGroup; + "capture of '*this' by copy is a C++17 extension">, InGroup; } def err_return_in_captured_stmt : Error< @@ -7200,7 +7200,7 @@ def warn_unused_volatile : Warning< def ext_cxx14_attr : Extension< "use of the %0 attribute is a C++14 extension">, InGroup; def ext_cxx1z_attr : Extension< - "use of the %0 attribute is a C++1z extension">, InGroup; + "use of the %0 attribute is a C++17 extension">, InGroup; def warn_unused_comparison : Warning< "%select{%select{|in}1equality|relational}0 comparison result unused">, diff --git a/contrib/llvm/tools/clang/include/clang/Driver/Options.td b/contrib/llvm/tools/clang/include/clang/Driver/Options.td index 3c0674f598d1..753c178eec6a 100644 --- a/contrib/llvm/tools/clang/include/clang/Driver/Options.td +++ b/contrib/llvm/tools/clang/include/clang/Driver/Options.td @@ -2019,6 +2019,10 @@ def mdspr2 : Flag<["-"], "mdspr2">, Group; def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group; def msingle_float : Flag<["-"], "msingle-float">, Group; def mdouble_float : Flag<["-"], "mdouble-float">, Group; +def mmadd4 : Flag<["-"], "mmadd4">, Group, + HelpText<"Enable the generation of 4-operand madd.s, madd.d and related instructions.">; +def mno_madd4 : Flag<["-"], "mno-madd4">, Group, + HelpText<"Disable the generation of 4-operand madd.s, madd.d and related instructions.">; def mmsa : Flag<["-"], "mmsa">, Group, HelpText<"Enable MSA ASE (MIPS only)">; def mno_msa : Flag<["-"], "mno-msa">, Group, diff --git a/contrib/llvm/tools/clang/include/clang/Driver/ToolChain.h b/contrib/llvm/tools/clang/include/clang/Driver/ToolChain.h index eb42f1260d92..6651491e5b27 100644 --- a/contrib/llvm/tools/clang/include/clang/Driver/ToolChain.h +++ b/contrib/llvm/tools/clang/include/clang/Driver/ToolChain.h @@ -315,7 +315,7 @@ class ToolChain { /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables /// by default. - virtual bool IsUnwindTablesDefault() const; + virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const; /// \brief Test whether this toolchain defaults to PIC. virtual bool isPICDefault() const = 0; diff --git a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def index 669e487023a5..a019d6392214 100644 --- a/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def +++ b/contrib/llvm/tools/clang/include/clang/Frontend/LangStandards.def @@ -109,15 +109,17 @@ LANGSTANDARD(gnucxx14, "gnu++14", GNUMode) LANGSTANDARD_ALIAS_DEPR(gnucxx14, "gnu++1y") -LANGSTANDARD(cxx1z, "c++1z", - CXX, "Working draft for ISO C++ 2017", +LANGSTANDARD(cxx17, "c++17", + CXX, "ISO C++ 2017 with amendments", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z | Digraphs | HexFloat) +LANGSTANDARD_ALIAS_DEPR(cxx17, "c++1z") -LANGSTANDARD(gnucxx1z, "gnu++1z", - CXX, "Working draft for ISO C++ 2017 with GNU extensions", +LANGSTANDARD(gnucxx17, "gnu++17", + CXX, "ISO C++ 2017 with amendments and GNU extensions", LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus1z | Digraphs | HexFloat | GNUMode) +LANGSTANDARD_ALIAS_DEPR(gnucxx17, "gnu++1z") LANGSTANDARD(cxx2a, "c++2a", CXX, "Working draft for ISO C++ 2020", diff --git a/contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp b/contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp index 5cab48882251..1caceab85eea 100644 --- a/contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp +++ b/contrib/llvm/tools/clang/lib/AST/DeclCXX.cpp @@ -1837,9 +1837,10 @@ bool CXXMethodDecl::hasInlineBody() const { const FunctionDecl *CheckFn = getTemplateInstantiationPattern(); if (!CheckFn) CheckFn = this; - + const FunctionDecl *fn; - return CheckFn->hasBody(fn) && !fn->isOutOfLine(); + return CheckFn->isDefined(fn) && !fn->isOutOfLine() && + (fn->doesThisDeclarationHaveABody() || fn->willHaveBody()); } bool CXXMethodDecl::isLambdaStaticInvoker() const { diff --git a/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp b/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp index 6713fca04571..fe45b5e47f36 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp @@ -1052,7 +1052,9 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, :Type->getType()->isRValueReferenceType()? VK_XValue :VK_RValue), OK_Ordinary, - Type->getType()->isDependentType(), true, true, + Type->getType()->isDependentType() || + Type->getType()->getContainedDeducedType(), + true, true, Type->getType()->containsUnexpandedParameterPack()), Type(Type), LParenLoc(LParenLoc), diff --git a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp index 0c0c861e5d56..a26b608082f5 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp @@ -9788,6 +9788,8 @@ class VoidExprEvaluator bool Success(const APValue &V, const Expr *e) { return true; } + bool ZeroInitialization(const Expr *E) { return true; } + bool VisitCastExpr(const CastExpr *E) { switch (E->getCastKind()) { default: diff --git a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp index 73be2e173fda..5d75aa5a7528 100644 --- a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp @@ -8050,6 +8050,7 @@ class MipsTargetInfo : public TargetInfo { NoDSP, DSP1, DSP2 } DspRev; bool HasMSA; + bool DisableMadd4; protected: bool HasFP64; @@ -8060,7 +8061,7 @@ class MipsTargetInfo : public TargetInfo { : TargetInfo(Triple), IsMips16(false), IsMicromips(false), IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP), - HasMSA(false), HasFP64(false) { + HasMSA(false), DisableMadd4(false), HasFP64(false) { TheCXXABI.set(TargetCXXABI::GenericMIPS); setABI((getTriple().getArch() == llvm::Triple::mips || @@ -8306,6 +8307,9 @@ class MipsTargetInfo : public TargetInfo { if (HasMSA) Builder.defineMacro("__mips_msa", Twine(1)); + if (DisableMadd4) + Builder.defineMacro("__mips_no_madd4", Twine(1)); + Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0))); Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth())); Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth())); @@ -8468,6 +8472,8 @@ class MipsTargetInfo : public TargetInfo { DspRev = std::max(DspRev, DSP2); else if (Feature == "+msa") HasMSA = true; + else if (Feature == "+nomadd4") + DisableMadd4 = true; else if (Feature == "+fp64") HasFP64 = true; else if (Feature == "-fp64") diff --git a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp index c17828974e92..eb230aad4d35 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp +++ b/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp @@ -5573,17 +5573,14 @@ void ARMABIInfo::setCCs() { // AAPCS apparently requires runtime support functions to be soft-float, but // that's almost certainly for historic reasons (Thumb1 not supporting VFP // most likely). It's more convenient for AAPCS16_VFP to be hard-float. - switch (getABIKind()) { - case APCS: - case AAPCS16_VFP: - if (abiCC != getLLVMDefaultCC()) + + // The Run-time ABI for the ARM Architecture section 4.1.2 requires + // AEABI-complying FP helper functions to use the base AAPCS. + // These AEABI functions are expanded in the ARM llvm backend, all the builtin + // support functions emitted by clang such as the _Complex helpers follow the + // abiCC. + if (abiCC != getLLVMDefaultCC()) BuiltinCC = abiCC; - break; - case AAPCS: - case AAPCS_VFP: - BuiltinCC = llvm::CallingConv::ARM_AAPCS; - break; - } } ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, @@ -6754,14 +6751,6 @@ MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const { return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); } - // Use indirect if the aggregate cannot fit into registers for - // passing arguments according to the ABI - unsigned Threshold = IsO32 ? 16 : 64; - - if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold)) - return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true, - getContext().getTypeAlign(Ty) / 8 > Align); - // If we have reached here, aggregates are passed directly by coercing to // another structure type. Padding is inserted if the offset of the // aggregate is unaligned. diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp index 2be7f0f69004..9a858df8ab2d 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp @@ -217,7 +217,7 @@ StringRef ToolChain::getDefaultUniversalArchName() const { } } -bool ToolChain::IsUnwindTablesDefault() const { +bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const { return false; } diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp index 1da90d1dc7ba..b45dcd6db678 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp @@ -297,6 +297,8 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple, AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg, options::OPT_modd_spreg, "nooddspreg"); + AddTargetFeature(Args, Features, options::OPT_mno_madd4, options::OPT_mmadd4, + "nomadd4"); AddTargetFeature(Args, Features, options::OPT_mlong_calls, options::OPT_mno_long_calls, "long-calls"); AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt,"mt"); diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp index b82cc2d4fa5d..baf7a93d2d92 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Clang.cpp @@ -2538,7 +2538,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, bool AsynchronousUnwindTables = Args.hasFlag(options::OPT_fasynchronous_unwind_tables, options::OPT_fno_asynchronous_unwind_tables, - (getToolChain().IsUnwindTablesDefault() || + (getToolChain().IsUnwindTablesDefault(Args) || getToolChain().getSanitizerArgs().needsUnwindTables()) && !KernelOrKext); if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables, diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.cpp index 7d0c438b1360..04b71c48cd4c 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.cpp @@ -214,7 +214,7 @@ CrossWindowsToolChain::CrossWindowsToolChain(const Driver &D, } } -bool CrossWindowsToolChain::IsUnwindTablesDefault() const { +bool CrossWindowsToolChain::IsUnwindTablesDefault(const ArgList &Args) const { // FIXME: all non-x86 targets need unwind tables, however, LLVM currently does // not know how to emit them. return getArch() == llvm::Triple::x86_64; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.h index 5375a6324a3f..2f66446ec732 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/CrossWindows.h @@ -56,7 +56,7 @@ class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC { const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override { return true; } - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp index 0d63858f2cd4..6b7f0c71dfb7 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1174,13 +1174,12 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { unsigned Major, Minor, Micro; bool HadExtra; - // iOS 10 is the maximum deployment target for 32-bit targets. - if (iOSVersion && getTriple().isArch32Bit() && - Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro, - HadExtra) && - Major > 10) - getDriver().Diag(diag::err_invalid_ios_deployment_target) - << iOSVersion->getAsString(Args); + // The iOS deployment target that is explicitly specified via a command line + // option or an environment variable. + std::string ExplicitIOSDeploymentTargetStr; + + if (iOSVersion) + ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args); // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and // -m(iphone|tv|watch)simulator-version-min=X.Y. @@ -1223,13 +1222,9 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET")) WatchOSTarget = env; - // iOS 10 is the maximum deployment target for 32-bit targets. - if (!iOSTarget.empty() && getTriple().isArch32Bit() && - Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro, - HadExtra) && - Major > 10) - getDriver().Diag(diag::err_invalid_ios_deployment_target) - << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget; + if (!iOSTarget.empty()) + ExplicitIOSDeploymentTargetStr = + std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget; // If there is no command-line argument to specify the Target version and // no environment variable defined, see if we can set the default based @@ -1393,12 +1388,19 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100) getDriver().Diag(diag::err_drv_invalid_version_number) << iOSVersion->getAsString(Args); - // iOS 10 is the maximum deployment target for 32-bit targets. If the - // inferred deployment target is iOS 11 or later, set it to 10.99. + // For 32-bit targets, the deployment target for iOS has to be earlier than + // iOS 11. if (getTriple().isArch32Bit() && Major >= 11) { - Major = 10; - Minor = 99; - Micro = 99; + // If the deployment target is explicitly specified, print a diagnostic. + if (!ExplicitIOSDeploymentTargetStr.empty()) { + getDriver().Diag(diag::warn_invalid_ios_deployment_target) + << ExplicitIOSDeploymentTargetStr; + // Otherwise, set it to 10.99.99. + } else { + Major = 10; + Minor = 99; + Micro = 99; + } } } else if (Platform == TvOS) { if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor, @@ -1834,8 +1836,8 @@ Darwin::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch, return DAL; } -bool MachO::IsUnwindTablesDefault() const { - return getArch() == llvm::Triple::x86_64; +bool MachO::IsUnwindTablesDefault(const ArgList &Args) const { + return !UseSjLjExceptions(Args); } bool MachO::UseDwarfDebugFlags() const { diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.h index 6cb1d04b78c0..77c569e8f865 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Darwin.h @@ -216,7 +216,7 @@ class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain { bool UseObjCMixedDispatch() const override { return true; } - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; RuntimeLibType GetDefaultRuntimeLibType() const override { return ToolChain::RLT_CompilerRT; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp index bc26ee1de46d..72a9f85ba389 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2291,7 +2291,7 @@ void Generic_GCC::printVerboseInfo(raw_ostream &OS) const { CudaInstallation.print(OS); } -bool Generic_GCC::IsUnwindTablesDefault() const { +bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const { return getArch() == llvm::Triple::x86_64; } diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.h index cdf610054401..f29342b95a07 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/Gnu.h @@ -284,7 +284,7 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain { void printVerboseInfo(raw_ostream &OS) const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp index 9e9d943610be..b871c856d2a0 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.cpp @@ -699,7 +699,7 @@ bool MSVCToolChain::IsIntegratedAssemblerDefault() const { return true; } -bool MSVCToolChain::IsUnwindTablesDefault() const { +bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const { // Emit unwind tables by default on Win64. All non-x86_32 Windows platforms // such as ARM and PPC actually require unwind tables, but LLVM doesn't know // how to generate them yet. diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h index 055830c52e0d..d153691a5c90 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MSVC.h @@ -73,7 +73,7 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain { Action::OffloadKind DeviceOffloadKind) const override; bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.cpp index 7550bab486f1..632b76d92bdd 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.cpp @@ -347,7 +347,7 @@ Tool *toolchains::MinGW::buildLinker() const { return new tools::MinGW::Linker(*this); } -bool toolchains::MinGW::IsUnwindTablesDefault() const { +bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { return getArch() == llvm::Triple::x86_64; } diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.h index cf1628a4ccdd..9b3d7c553f1d 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/MinGW.h @@ -60,7 +60,7 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { const llvm::opt::ArgList &Args); bool IsIntegratedAssemblerDefault() const override; - bool IsUnwindTablesDefault() const override; + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; bool isPIEDefault() const override; bool isPICDefaultForced() const override; diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains/NetBSD.h b/contrib/llvm/tools/clang/lib/Driver/ToolChains/NetBSD.h index 412d0815e81a..5163ff72d81b 100644 --- a/contrib/llvm/tools/clang/lib/Driver/ToolChains/NetBSD.h +++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains/NetBSD.h @@ -65,7 +65,10 @@ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF { const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override; - bool IsUnwindTablesDefault() const override { return true; } + bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override { + return true; + } + SanitizerMask getSupportedSanitizers() const override; protected: diff --git a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp index 64128dfdf534..92d61369b40f 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp @@ -497,6 +497,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_ref_qualifiers", "200710"); Builder.defineMacro("__cpp_alias_templates", "200704"); } + if (LangOpts.ThreadsafeStatics) + Builder.defineMacro("__cpp_threadsafe_static_init", "200806"); // C++14 features. if (LangOpts.CPlusPlus14) { @@ -519,6 +521,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_noexcept_function_type", "201510"); Builder.defineMacro("__cpp_capture_star_this", "201603"); Builder.defineMacro("__cpp_if_constexpr", "201606"); + Builder.defineMacro("__cpp_deduction_guides", "201611"); Builder.defineMacro("__cpp_template_auto", "201606"); Builder.defineMacro("__cpp_namespace_attributes", "201411"); Builder.defineMacro("__cpp_enumerator_attributes", "201411"); @@ -528,8 +531,6 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts, Builder.defineMacro("__cpp_structured_bindings", "201606"); Builder.defineMacro("__cpp_nontype_template_args", "201411"); Builder.defineMacro("__cpp_fold_expressions", "201603"); - // FIXME: This is not yet listed in SD-6. - Builder.defineMacro("__cpp_deduction_guides", "201611"); } if (LangOpts.AlignedAllocation) Builder.defineMacro("__cpp_aligned_new", "201606"); diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp index b68559485a5e..27651c9ca85c 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/contrib/llvm/tools/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -166,20 +166,11 @@ NamedDecl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, } if (FnD) { - // If this is a friend function, mark that it's late-parsed so that - // it's still known to be a definition even before we attach the - // parsed body. Sema needs to treat friend function definitions - // differently during template instantiation, and it's possible for - // the containing class to be instantiated before all its member - // function definitions are parsed. - // - // If you remove this, you can remove the code that clears the flag - // after parsing the member. - if (D.getDeclSpec().isFriendSpecified()) { - FunctionDecl *FD = FnD->getAsFunction(); - Actions.CheckForFunctionRedefinition(FD); - FD->setLateTemplateParsed(true); - } + FunctionDecl *FD = FnD->getAsFunction(); + // Track that this function will eventually have a body; Sema needs + // to know this. + Actions.CheckForFunctionRedefinition(FD); + FD->setWillHaveBody(true); } else { // If semantic analysis could not build a function declaration, // just throw away the late-parsed declaration. @@ -558,10 +549,6 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) { ParseFunctionStatementBody(LM.D, FnScope); - // Clear the late-template-parsed bit if we set it before. - if (LM.D) - LM.D->getAsFunction()->setLateTemplateParsed(false); - while (Tok.isNot(tok::eof)) ConsumeAnyToken(); diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaCast.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaCast.cpp index ba2049d8a606..d603101c3fd9 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaCast.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaCast.cpp @@ -552,7 +552,14 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, Qualifiers SrcQuals, DestQuals; Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals); Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals); - + + // We do not meaningfully track object const-ness of Objective-C object + // types. Remove const from the source type if either the source or + // the destination is an Objective-C object type. + if (UnwrappedSrcType->isObjCObjectType() || + UnwrappedDestType->isObjCObjectType()) + SrcQuals.removeConst(); + Qualifiers RetainedSrcQuals, RetainedDestQuals; if (CheckCVR) { RetainedSrcQuals.setCVRQualifiers(SrcQuals.getCVRQualifiers()); diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaCodeComplete.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaCodeComplete.cpp index 91a8c619b26c..4de7d422072d 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaCodeComplete.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaCodeComplete.cpp @@ -2401,10 +2401,7 @@ formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts) { - const Expr *defaultArg = Param->getDefaultArg(); - if (!defaultArg) - return ""; - const SourceRange SrcRange = defaultArg->getSourceRange(); + const SourceRange SrcRange = Param->getDefaultArgRange(); CharSourceRange CharSrcRange = CharSourceRange::getTokenRange(SrcRange); bool Invalid = CharSrcRange.isInvalid(); if (Invalid) diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp index 31b24f91c1d9..692a77e2b62f 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp @@ -6999,6 +6999,21 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, return; } } + + if (cast(ShadowedDecl)->hasLocalStorage()) { + // A variable can't shadow a local variable in an enclosing scope, if + // they are separated by a non-capturing declaration context. + for (DeclContext *ParentDC = NewDC; + ParentDC && !ParentDC->Equals(OldDC); + ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) { + // Only block literals, captured statements, and lambda expressions + // can capture; other scopes don't. + if (!isa(ParentDC) && !isa(ParentDC) && + !isLambdaCallOperator(ParentDC)) { + return; + } + } + } } } @@ -12075,8 +12090,9 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, FD->setInvalidDecl(); } - // See if this is a redefinition. - if (!FD->isLateTemplateParsed()) { + // See if this is a redefinition. If 'will have body' is already set, then + // these checks were already performed when it was set. + if (!FD->willHaveBody() && !FD->isLateTemplateParsed()) { CheckForFunctionRedefinition(FD, nullptr, SkipBody); // If we're skipping the body, we're done. Don't enter the scope. @@ -13278,6 +13294,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, AddMsStructLayoutForRecord(RD); } } + New->setLexicalDeclContext(CurContext); return New; }; diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index abe912fb548b..6fee23aa8bc1 100644 --- a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3771,6 +3771,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (PatternDef) { Pattern = PatternDef->getBody(PatternDef); PatternDecl = PatternDef; + if (PatternDef->willHaveBody()) + PatternDef = nullptr; } // FIXME: We need to track the instantiation stack in order to know which diff --git a/contrib/llvm/tools/lld/COFF/Driver.cpp b/contrib/llvm/tools/lld/COFF/Driver.cpp index 6df59e4b08df..854c3e690981 100644 --- a/contrib/llvm/tools/lld/COFF/Driver.cpp +++ b/contrib/llvm/tools/lld/COFF/Driver.cpp @@ -458,8 +458,8 @@ static void createImportLibrary(bool AsLib) { std::vector Exports; for (Export &E1 : Config->Exports) { COFFShortExport E2; - // Use SymbolName, which will have any stdcall or fastcall qualifiers. - E2.Name = E1.SymbolName; + E2.Name = E1.Name; + E2.SymbolName = E1.SymbolName; E2.ExtName = E1.ExtName; E2.Ordinal = E1.Ordinal; E2.Noname = E1.Noname; @@ -470,7 +470,7 @@ static void createImportLibrary(bool AsLib) { } writeImportLibrary(getImportName(AsLib), getImplibPath(), Exports, - Config->Machine); + Config->Machine, false); } static void parseModuleDefs(StringRef Path) { diff --git a/contrib/llvm/tools/lld/ELF/Driver.cpp b/contrib/llvm/tools/lld/ELF/Driver.cpp index 7c5404e2f20b..be5bd8ab5194 100644 --- a/contrib/llvm/tools/lld/ELF/Driver.cpp +++ b/contrib/llvm/tools/lld/ELF/Driver.cpp @@ -639,7 +639,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { Config->Fini = Args.getLastArgValue(OPT_fini, "_fini"); Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false); Config->GdbIndex = Args.hasArg(OPT_gdb_index); - Config->ICF = Args.hasArg(OPT_icf); + Config->ICF = getArg(Args, OPT_icf_all, OPT_icf_none, false); Config->Init = Args.getLastArgValue(OPT_init, "_init"); Config->LTOAAPipeline = Args.getLastArgValue(OPT_lto_aa_pipeline); Config->LTONewPmPasses = Args.getLastArgValue(OPT_lto_newpm_passes); diff --git a/contrib/llvm/tools/lld/ELF/Options.td b/contrib/llvm/tools/lld/ELF/Options.td index 9c78608118cc..1400a206bdfc 100644 --- a/contrib/llvm/tools/lld/ELF/Options.td +++ b/contrib/llvm/tools/lld/ELF/Options.td @@ -126,7 +126,9 @@ def hash_style: S<"hash-style">, def help: F<"help">, HelpText<"Print option help">; -def icf: F<"icf=all">, HelpText<"Enable identical code folding">; +def icf_all: F<"icf=all">, HelpText<"Enable identical code folding">; + +def icf_none: F<"icf=none">, HelpText<"Disable identical code folding">; def image_base : J<"image-base=">, HelpText<"Set the base address">; diff --git a/contrib/llvm/tools/llvm-objdump/llvm-objdump.cpp b/contrib/llvm/tools/llvm-objdump/llvm-objdump.cpp index d54b45515f05..74593e6202aa 100644 --- a/contrib/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/contrib/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -871,7 +871,7 @@ static void printRelocationTargetName(const MachOObjectFile *O, uint64_t Val = O->getPlainRelocationSymbolNum(RE); if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) { - fmt << format("0x%x", Val); + fmt << format("0x%0" PRIx64, Val); return; } else if (isExtern) { symbol_iterator SI = O->symbol_begin(); diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc index 2a8168733a35..7a9a4f7cc287 100644 --- a/lib/clang/include/clang/Basic/Version.inc +++ b/lib/clang/include/clang/Basic/Version.inc @@ -8,4 +8,4 @@ #define CLANG_VENDOR "FreeBSD " -#define SVN_REVISION "310316" +#define SVN_REVISION "311219" diff --git a/lib/clang/include/lld/Config/Version.inc b/lib/clang/include/lld/Config/Version.inc index ef92c2ddbac0..c506bdf0fc83 100644 --- a/lib/clang/include/lld/Config/Version.inc +++ b/lib/clang/include/lld/Config/Version.inc @@ -4,5 +4,5 @@ #define LLD_VERSION_STRING "5.0.0" #define LLD_VERSION_MAJOR 5 #define LLD_VERSION_MINOR 0 -#define LLD_REVISION_STRING "310316" +#define LLD_REVISION_STRING "311219" #define LLD_REPOSITORY_STRING "FreeBSD" diff --git a/lib/clang/include/llvm/Support/VCSRevision.h b/lib/clang/include/llvm/Support/VCSRevision.h index 256c374a0696..8060bd4818f8 100644 --- a/lib/clang/include/llvm/Support/VCSRevision.h +++ b/lib/clang/include/llvm/Support/VCSRevision.h @@ -1,2 +1,2 @@ /* $FreeBSD$ */ -#define LLVM_REVISION "svn-r310316" +#define LLVM_REVISION "svn-r311219"