aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
commit08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (patch)
tree80108f0f128657f8623f8f66ad9735b4d88e7b47
parent7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (diff)
downloadsrc-08bbd35a80bf7765fe0d3043f9eb5a2f2786b649.tar.gz
src-08bbd35a80bf7765fe0d3043f9eb5a2f2786b649.zip
Vendor import of llvm trunk r306325:vendor/llvm/llvm-trunk-r306325
Notes
Notes: svn path=/vendor/llvm/dist/; revision=320374 svn path=/vendor/llvm/llvm-trunk-r306325/; revision=320375; tag=vendor/llvm/llvm-trunk-r306325
-rw-r--r--CMakeLists.txt9
-rw-r--r--CODE_OWNERS.TXT1
-rw-r--r--CREDITS.TXT2
-rwxr-xr-xcmake/modules/AddLLVM.cmake13
-rw-r--r--cmake/modules/HandleLLVMOptions.cmake3
-rw-r--r--cmake/modules/TableGen.cmake32
-rw-r--r--docs/AMDGPUUsage.rst20
-rw-r--r--docs/GetElementPtr.rst20
-rw-r--r--docs/GoldPlugin.rst20
-rw-r--r--docs/LangRef.rst34
-rw-r--r--docs/Proposals/VectorizationPlan.rst2
-rw-r--r--docs/XRay.rst2
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h18
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h24
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h24
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h24
-rw-r--r--examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h24
-rw-r--r--examples/Kaleidoscope/include/KaleidoscopeJIT.h20
-rw-r--r--include/llvm-c/OrcBindings.h49
-rw-r--r--include/llvm/ADT/APFloat.h2
-rw-r--r--include/llvm/ADT/APInt.h28
-rw-r--r--include/llvm/ADT/StringExtras.h28
-rw-r--r--include/llvm/ADT/Triple.h1
-rw-r--r--include/llvm/Analysis/LazyValueInfo.h7
-rw-r--r--include/llvm/Analysis/Loads.h9
-rw-r--r--include/llvm/Analysis/LoopInfoImpl.h9
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h32
-rw-r--r--include/llvm/BinaryFormat/COFF.h6
-rw-r--r--include/llvm/BinaryFormat/Dwarf.h2
-rw-r--r--include/llvm/BinaryFormat/MachO.h3
-rw-r--r--include/llvm/BinaryFormat/Wasm.h5
-rw-r--r--include/llvm/CodeGen/DIE.h6
-rw-r--r--include/llvm/CodeGen/GlobalISel/InstructionSelector.h11
-rw-r--r--include/llvm/CodeGen/GlobalISel/Legalizer.h2
-rw-r--r--include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h33
-rw-r--r--include/llvm/CodeGen/GlobalISel/Utils.h15
-rw-r--r--include/llvm/CodeGen/LexicalScopes.h2
-rw-r--r--include/llvm/CodeGen/MachineBasicBlock.h3
-rw-r--r--include/llvm/CodeGen/MachineMemOperand.h5
-rw-r--r--include/llvm/CodeGen/MachineModuleInfoImpls.h27
-rw-r--r--include/llvm/CodeGen/MachineScheduler.h8
-rw-r--r--include/llvm/CodeGen/MacroFusion.h41
-rw-r--r--include/llvm/CodeGen/RegisterScavenging.h18
-rw-r--r--include/llvm/CodeGen/SelectionDAGAddressAnalysis.h64
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h2
-rw-r--r--include/llvm/Config/config.h.cmake3
-rw-r--r--include/llvm/DebugInfo/CodeView/CVRecord.h5
-rw-r--r--include/llvm/DebugInfo/CodeView/CodeView.h10
-rw-r--r--include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h12
-rw-r--r--include/llvm/DebugInfo/CodeView/EnumTables.h1
-rw-r--r--include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h41
-rw-r--r--include/llvm/DebugInfo/CodeView/SymbolRecord.h2
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeDatabase.h84
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h62
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h6
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeName.h22
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeRecordMapping.h1
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeSerializer.h1
-rw-r--r--include/llvm/DebugInfo/CodeView/TypeTableCollection.h11
-rw-r--r--include/llvm/DebugInfo/DIContext.h5
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h7
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h5
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFContext.h22
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h10
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h4
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h4
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugLine.h40
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h4
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h2
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h4
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFFormValue.h113
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFRelocMap.h3
-rw-r--r--include/llvm/DebugInfo/DWARF/DWARFUnit.h48
-rw-r--r--include/llvm/DebugInfo/MSF/MSFBuilder.h13
-rw-r--r--include/llvm/DebugInfo/MSF/MSFCommon.h18
-rw-r--r--include/llvm/DebugInfo/MSF/MappedBlockStream.h20
-rw-r--r--include/llvm/DebugInfo/PDB/DIA/DIASession.h2
-rw-r--r--include/llvm/DebugInfo/PDB/IPDBSession.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiStream.h17
-rw-r--r--include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h1
-rw-r--r--include/llvm/DebugInfo/PDB/Native/InfoStream.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h19
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h6
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h4
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h5
-rw-r--r--include/llvm/DebugInfo/PDB/Native/NativeSession.h2
-rw-r--r--include/llvm/DebugInfo/PDB/Native/PDBFile.h3
-rw-r--r--include/llvm/DebugInfo/PDB/Native/TpiStream.h5
-rw-r--r--include/llvm/DebugInfo/Symbolize/SymbolizableModule.h16
-rw-r--r--include/llvm/DebugInfo/Symbolize/Symbolize.h21
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h41
-rw-r--r--include/llvm/ExecutionEngine/GenericValue.h33
-rw-r--r--include/llvm/ExecutionEngine/JITEventListener.h8
-rw-r--r--include/llvm/ExecutionEngine/JITSymbol.h28
-rw-r--r--include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h80
-rw-r--r--include/llvm/ExecutionEngine/Orc/CompileUtils.h71
-rw-r--r--include/llvm/ExecutionEngine/Orc/ExecutionUtils.h28
-rw-r--r--include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h9
-rw-r--r--include/llvm/ExecutionEngine/Orc/IRCompileLayer.h129
-rw-r--r--include/llvm/ExecutionEngine/Orc/IRTransformLayer.h61
-rw-r--r--include/llvm/ExecutionEngine/Orc/IndirectionUtils.h26
-rw-r--r--include/llvm/ExecutionEngine/Orc/LambdaResolver.h11
-rw-r--r--include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h125
-rw-r--r--include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h32
-rw-r--r--include/llvm/ExecutionEngine/Orc/OrcABISupport.h47
-rw-r--r--include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h31
-rw-r--r--include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h15
-rw-r--r--include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h38
-rw-r--r--include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h206
-rw-r--r--include/llvm/ExecutionEngine/Orc/RawByteChannel.h10
-rw-r--r--include/llvm/ExecutionEngine/RuntimeDyld.h12
-rw-r--r--include/llvm/IR/Attributes.h7
-rw-r--r--include/llvm/IR/Attributes.td2
-rw-r--r--include/llvm/IR/BasicBlock.h15
-rw-r--r--include/llvm/IR/ConstantRange.h9
-rw-r--r--include/llvm/IR/DerivedUser.h12
-rw-r--r--include/llvm/IR/InstrTypes.h4
-rw-r--r--include/llvm/IR/Instruction.h7
-rw-r--r--include/llvm/IR/Instructions.h34
-rw-r--r--include/llvm/IR/IntrinsicsAMDGPU.td27
-rw-r--r--include/llvm/IR/IntrinsicsX86.td80
-rw-r--r--include/llvm/IR/Metadata.h63
-rw-r--r--include/llvm/IR/ModuleSummaryIndexYAML.h2
-rw-r--r--include/llvm/IR/Operator.h9
-rw-r--r--include/llvm/IR/PatternMatch.h209
-rw-r--r--include/llvm/IR/Statepoint.h3
-rw-r--r--include/llvm/IR/Value.h7
-rw-r--r--include/llvm/InitializePasses.h1
-rw-r--r--include/llvm/LTO/legacy/ThinLTOCodeGenerator.h2
-rw-r--r--include/llvm/MC/MCAsmBackend.h13
-rw-r--r--include/llvm/MC/MCAssembler.h6
-rw-r--r--include/llvm/MC/MCFragment.h2
-rw-r--r--include/llvm/MC/MCSection.h2
-rw-r--r--include/llvm/MC/MCSymbolWasm.h4
-rw-r--r--include/llvm/MC/MCValue.h2
-rw-r--r--include/llvm/MC/MCWinCOFFObjectWriter.h4
-rw-r--r--include/llvm/Object/COFF.h100
-rw-r--r--include/llvm/Object/IRSymtab.h6
-rw-r--r--include/llvm/Object/MachO.h6
-rw-r--r--include/llvm/Object/Wasm.h31
-rw-r--r--include/llvm/Object/WindowsResource.h57
-rw-r--r--include/llvm/ObjectYAML/WasmYAML.h36
-rw-r--r--include/llvm/Option/OptParser.td2
-rw-r--r--include/llvm/Option/OptTable.h14
-rw-r--r--include/llvm/Option/Option.h2
-rw-r--r--include/llvm/ProfileData/Coverage/CoverageMapping.h13
-rw-r--r--include/llvm/ProfileData/InstrProf.h31
-rw-r--r--include/llvm/ProfileData/InstrProfReader.h28
-rw-r--r--include/llvm/ProfileData/InstrProfWriter.h5
-rw-r--r--include/llvm/ProfileData/SampleProf.h13
-rw-r--r--include/llvm/ProfileData/SampleProfReader.h8
-rw-r--r--include/llvm/Support/BinaryStreamReader.h9
-rw-r--r--include/llvm/Support/BinaryStreamRef.h22
-rw-r--r--include/llvm/Support/CachePruning.h9
-rw-r--r--include/llvm/Support/DataExtractor.h41
-rw-r--r--include/llvm/Support/Errno.h1
-rw-r--r--include/llvm/Support/Error.h21
-rw-r--r--include/llvm/Support/GCOV.h18
-rw-r--r--include/llvm/Support/GenericDomTree.h79
-rw-r--r--include/llvm/Support/GenericDomTreeConstruction.h45
-rw-r--r--include/llvm/Support/GraphWriter.h52
-rw-r--r--include/llvm/Support/Host.h10
-rw-r--r--include/llvm/Support/Path.h11
-rw-r--r--include/llvm/Support/Solaris/sys/regset.h (renamed from include/llvm/Support/Solaris.h)20
-rw-r--r--include/llvm/Support/TargetRegistry.h103
-rw-r--r--include/llvm/Support/YAMLParser.h97
-rw-r--r--include/llvm/Support/YAMLTraits.h182
-rw-r--r--include/llvm/TableGen/Main.h4
-rw-r--r--include/llvm/Target/GenericOpcodes.td18
-rw-r--r--include/llvm/Target/TargetInstrInfo.h65
-rw-r--r--include/llvm/Target/TargetLowering.h70
-rw-r--r--include/llvm/Target/TargetOpcodes.def5
-rw-r--r--include/llvm/Target/TargetRegisterInfo.h54
-rw-r--r--include/llvm/Target/TargetSubtargetInfo.h24
-rw-r--r--include/llvm/Testing/Support/Error.h4
-rw-r--r--include/llvm/Transforms/IPO/PassManagerBuilder.h1
-rw-r--r--include/llvm/Transforms/InstrProfiling.h16
-rw-r--r--include/llvm/Transforms/Instrumentation.h3
-rw-r--r--include/llvm/Transforms/Scalar.h6
-rw-r--r--include/llvm/Transforms/Scalar/GVN.h32
-rw-r--r--include/llvm/Transforms/Scalar/Reassociate.h2
-rw-r--r--include/llvm/Transforms/Utils/Local.h13
-rw-r--r--include/llvm/Transforms/Utils/LoopUtils.h8
-rw-r--r--include/llvm/Transforms/Utils/OrderedInstructions.h3
-rw-r--r--include/llvm/Transforms/Vectorize/LoopVectorize.h2
-rw-r--r--include/llvm/module.modulemap6
-rw-r--r--lib/Analysis/AliasSetTracker.cpp4
-rw-r--r--lib/Analysis/AssumptionCache.cpp11
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp19
-rw-r--r--lib/Analysis/CFLSteensAliasAnalysis.cpp3
-rw-r--r--lib/Analysis/DemandedBits.cpp2
-rw-r--r--lib/Analysis/InlineCost.cpp16
-rw-r--r--lib/Analysis/InstructionSimplify.cpp6
-rw-r--r--lib/Analysis/LazyValueInfo.cpp30
-rw-r--r--lib/Analysis/Loads.cpp10
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp6
-rw-r--r--lib/Analysis/ScalarEvolution.cpp133
-rw-r--r--lib/Analysis/ScalarEvolutionExpander.cpp48
-rw-r--r--lib/Analysis/TypeBasedAliasAnalysis.cpp2
-rw-r--r--lib/Analysis/ValueTracking.cpp7
-rw-r--r--lib/BinaryFormat/Magic.cpp3
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp14
-rw-r--r--lib/CodeGen/AsmPrinter/DIE.cpp6
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp68
-rw-r--r--lib/CodeGen/CMakeLists.txt1
-rw-r--r--lib/CodeGen/CodeGenPrepare.cpp54
-rw-r--r--lib/CodeGen/GlobalISel/IRTranslator.cpp9
-rw-r--r--lib/CodeGen/GlobalISel/InstructionSelector.cpp12
-rw-r--r--lib/CodeGen/GlobalISel/Legalizer.cpp139
-rw-r--r--lib/CodeGen/GlobalISel/LegalizerInfo.cpp3
-rw-r--r--lib/CodeGen/GlobalISel/MachineIRBuilder.cpp34
-rw-r--r--lib/CodeGen/GlobalISel/Utils.cpp28
-rw-r--r--lib/CodeGen/IfConversion.cpp13
-rw-r--r--lib/CodeGen/ImplicitNullChecks.cpp39
-rw-r--r--lib/CodeGen/LiveDebugVariables.cpp2
-rw-r--r--lib/CodeGen/LiveDebugVariables.h2
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp6
-rw-r--r--lib/CodeGen/MachineInstr.cpp18
-rw-r--r--lib/CodeGen/MachineModuleInfoImpls.cpp1
-rw-r--r--lib/CodeGen/MachineScheduler.cpp172
-rw-r--r--lib/CodeGen/MacroFusion.cpp150
-rw-r--r--lib/CodeGen/RegisterScavenging.cpp428
-rw-r--r--lib/CodeGen/RegisterUsageInfo.cpp4
-rw-r--r--lib/CodeGen/SelectionDAG/CMakeLists.txt1
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp256
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp29
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp3
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp78
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp33
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp95
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp15
-rw-r--r--lib/CodeGen/SelectionDAG/TargetLowering.cpp24
-rw-r--r--lib/CodeGen/TargetRegisterInfo.cpp20
-rw-r--r--lib/CodeGen/TargetSubtargetInfo.cpp14
-rw-r--r--lib/DebugInfo/CodeView/CMakeLists.txt3
-rw-r--r--lib/DebugInfo/CodeView/CVTypeVisitor.cpp2
-rw-r--r--lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp30
-rw-r--r--lib/DebugInfo/CodeView/EnumTables.cpp10
-rw-r--r--lib/DebugInfo/CodeView/LazyRandomTypeCollection.cpp157
-rw-r--r--lib/DebugInfo/CodeView/SymbolDumper.cpp2
-rw-r--r--lib/DebugInfo/CodeView/SymbolRecordMapping.cpp2
-rw-r--r--lib/DebugInfo/CodeView/TypeDatabase.cpp146
-rw-r--r--lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp330
-rw-r--r--lib/DebugInfo/CodeView/TypeDumpVisitor.cpp2
-rw-r--r--lib/DebugInfo/CodeView/TypeIndexDiscovery.cpp82
-rw-r--r--lib/DebugInfo/CodeView/TypeName.cpp243
-rw-r--r--lib/DebugInfo/CodeView/TypeTableCollection.cpp58
-rw-r--r--lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp80
-rw-r--r--lib/DebugInfo/DWARF/DWARFContext.cpp15
-rw-r--r--lib/DebugInfo/DWARF/DWARFDebugFrame.cpp36
-rw-r--r--lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp2
-rw-r--r--lib/DebugInfo/DWARF/DWARFDebugLine.cpp52
-rw-r--r--lib/DebugInfo/DWARF/DWARFFormValue.cpp113
-rw-r--r--lib/DebugInfo/DWARF/DWARFUnit.cpp42
-rw-r--r--lib/DebugInfo/DWARF/DWARFVerifier.cpp6
-rw-r--r--lib/DebugInfo/MSF/MSFBuilder.cpp27
-rw-r--r--lib/DebugInfo/MSF/MSFCommon.cpp6
-rw-r--r--lib/DebugInfo/MSF/MappedBlockStream.cpp23
-rw-r--r--lib/DebugInfo/PDB/DIA/DIASession.cpp2
-rw-r--r--lib/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.cpp8
-rw-r--r--lib/DebugInfo/PDB/Native/DbiStream.cpp52
-rw-r--r--lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp9
-rw-r--r--lib/DebugInfo/PDB/Native/InfoStream.cpp8
-rw-r--r--lib/DebugInfo/PDB/Native/ModuleDebugStream.cpp36
-rw-r--r--lib/DebugInfo/PDB/Native/NamedStreamMap.cpp24
-rw-r--r--lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp9
-rw-r--r--lib/DebugInfo/PDB/Native/NativeEnumModules.cpp2
-rw-r--r--lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp9
-rw-r--r--lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp8
-rw-r--r--lib/DebugInfo/PDB/Native/NativeSession.cpp7
-rw-r--r--lib/DebugInfo/PDB/Native/PDBFile.cpp8
-rw-r--r--lib/DebugInfo/PDB/Native/TpiStream.cpp12
-rw-r--r--lib/ExecutionEngine/Orc/OrcCBindings.cpp32
-rw-r--r--lib/ExecutionEngine/Orc/OrcCBindingsStack.h82
-rw-r--r--lib/ExecutionEngine/Orc/OrcMCJITReplacement.cpp5
-rw-r--r--lib/ExecutionEngine/Orc/OrcMCJITReplacement.h119
-rw-r--r--lib/IR/AsmWriter.cpp147
-rw-r--r--lib/IR/AttributeImpl.h5
-rw-r--r--lib/IR/Attributes.cpp33
-rw-r--r--lib/IR/AutoUpgrade.cpp39
-rw-r--r--lib/IR/BasicBlock.cpp13
-rw-r--r--lib/IR/ConstantRange.cpp30
-rw-r--r--lib/IR/Instructions.cpp25
-rw-r--r--lib/IR/LLVMContextImpl.cpp30
-rw-r--r--lib/IR/LLVMContextImpl.h148
-rw-r--r--lib/IR/Metadata.cpp14
-rw-r--r--lib/IR/Statepoint.cpp12
-rw-r--r--lib/LTO/ThinLTOCodeGenerator.cpp1
-rw-r--r--lib/MC/CMakeLists.txt2
-rw-r--r--lib/MC/ELFObjectWriter.cpp3
-rw-r--r--lib/MC/MCAssembler.cpp36
-rw-r--r--lib/MC/MCFragment.cpp18
-rw-r--r--lib/MC/MCSection.cpp2
-rw-r--r--lib/MC/MCWasmStreamer.cpp12
-rw-r--r--lib/MC/MCWinCOFFStreamer.cpp (renamed from lib/MC/WinCOFFStreamer.cpp)8
-rw-r--r--lib/MC/WasmObjectWriter.cpp318
-rw-r--r--lib/MC/WinCOFFObjectWriter.cpp24
-rw-r--r--lib/Object/COFFObjectFile.cpp20
-rw-r--r--lib/Object/IRSymtab.cpp36
-rw-r--r--lib/Object/MachOObjectFile.cpp39
-rw-r--r--lib/Object/WasmObjectFile.cpp93
-rw-r--r--lib/Object/WindowsResource.cpp270
-rw-r--r--lib/ObjectYAML/CodeViewYAMLSymbols.cpp57
-rw-r--r--lib/ObjectYAML/CodeViewYAMLTypes.cpp2
-rw-r--r--lib/ObjectYAML/WasmYAML.cpp50
-rw-r--r--lib/Option/OptTable.cpp34
-rw-r--r--lib/Option/Option.cpp1
-rw-r--r--lib/Passes/PassBuilder.cpp8
-rw-r--r--lib/ProfileData/Coverage/CoverageMapping.cpp10
-rw-r--r--lib/ProfileData/Coverage/CoverageMappingReader.cpp18
-rw-r--r--lib/ProfileData/InstrProf.cpp12
-rw-r--r--lib/ProfileData/InstrProfReader.cpp16
-rw-r--r--lib/ProfileData/InstrProfWriter.cpp21
-rw-r--r--lib/Support/APFloat.cpp67
-rw-r--r--lib/Support/APInt.cpp9
-rw-r--r--lib/Support/BinaryStreamReader.cpp6
-rw-r--r--lib/Support/CachePruning.cpp55
-rw-r--r--lib/Support/CommandLine.cpp11
-rw-r--r--lib/Support/DataExtractor.cpp7
-rw-r--r--lib/Support/GraphWriter.cpp19
-rw-r--r--lib/Support/Triple.cpp2
-rw-r--r--lib/Support/Unix/Host.inc6
-rw-r--r--lib/Support/Unix/Memory.inc4
-rw-r--r--lib/Support/Unix/Program.inc13
-rw-r--r--lib/Support/Windows/Host.inc10
-rw-r--r--lib/Support/YAMLParser.cpp58
-rw-r--r--lib/Support/YAMLTraits.cpp50
-rw-r--r--lib/Support/raw_ostream.cpp4
-rw-r--r--lib/Target/AArch64/AArch64.h2
-rw-r--r--lib/Target/AArch64/AArch64CondBrTuning.cpp336
-rw-r--r--lib/Target/AArch64/AArch64DeadRegisterDefinitionsPass.cpp47
-rw-r--r--lib/Target/AArch64/AArch64ISelDAGToDAG.cpp15
-rw-r--r--lib/Target/AArch64/AArch64ISelLowering.cpp11
-rw-r--r--lib/Target/AArch64/AArch64InstrAtomics.td46
-rw-r--r--lib/Target/AArch64/AArch64InstrInfo.cpp6
-rw-r--r--lib/Target/AArch64/AArch64InstrInfo.h38
-rw-r--r--lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp20
-rw-r--r--lib/Target/AArch64/AArch64MacroFusion.cpp183
-rw-r--r--lib/Target/AArch64/AArch64MacroFusion.h11
-rw-r--r--lib/Target/AArch64/AArch64RegisterBankInfo.cpp4
-rw-r--r--lib/Target/AArch64/AArch64SchedA57.td2
-rw-r--r--lib/Target/AArch64/AArch64SchedFalkorDetails.td421
-rw-r--r--lib/Target/AArch64/AArch64SchedKryoDetails.td6
-rw-r--r--lib/Target/AArch64/AArch64TargetMachine.cpp7
-rw-r--r--lib/Target/AArch64/CMakeLists.txt1
-rw-r--r--lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp70
-rw-r--r--lib/Target/AMDGPU/AMDGPU.td47
-rw-r--r--lib/Target/AMDGPU/AMDGPUISelLowering.cpp23
-rw-r--r--lib/Target/AMDGPU/AMDGPUISelLowering.h25
-rw-r--r--lib/Target/AMDGPU/AMDGPUInstrInfo.cpp11
-rw-r--r--lib/Target/AMDGPU/AMDGPUInstrInfo.td10
-rw-r--r--lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp10
-rw-r--r--lib/Target/AMDGPU/AMDGPUSubtarget.cpp5
-rw-r--r--lib/Target/AMDGPU/AMDGPUSubtarget.h25
-rw-r--r--lib/Target/AMDGPU/AMDGPUTargetMachine.cpp8
-rw-r--r--lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp22
-rw-r--r--lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h6
-rw-r--r--lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp151
-rw-r--r--lib/Target/AMDGPU/BUFInstructions.td411
-rw-r--r--lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp100
-rw-r--r--lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h10
-rw-r--r--lib/Target/AMDGPU/FLATInstructions.td70
-rw-r--r--lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.cpp34
-rw-r--r--lib/Target/AMDGPU/InstPrinter/AMDGPUInstPrinter.h8
-rw-r--r--lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp48
-rw-r--r--lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCCodeEmitter.h12
-rw-r--r--lib/Target/AMDGPU/MCTargetDesc/SIMCCodeEmitter.cpp64
-rw-r--r--lib/Target/AMDGPU/Processors.td4
-rw-r--r--lib/Target/AMDGPU/R600ISelLowering.cpp24
-rw-r--r--lib/Target/AMDGPU/SIDefines.h6
-rw-r--r--lib/Target/AMDGPU/SIFixSGPRCopies.cpp30
-rw-r--r--lib/Target/AMDGPU/SIFoldOperands.cpp12
-rw-r--r--lib/Target/AMDGPU/SIFrameLowering.cpp83
-rw-r--r--lib/Target/AMDGPU/SIFrameLowering.h4
-rw-r--r--lib/Target/AMDGPU/SIISelLowering.cpp261
-rw-r--r--lib/Target/AMDGPU/SIISelLowering.h5
-rw-r--r--lib/Target/AMDGPU/SIInstrInfo.cpp71
-rw-r--r--lib/Target/AMDGPU/SIInstrInfo.h3
-rw-r--r--lib/Target/AMDGPU/SIInstrInfo.td195
-rw-r--r--lib/Target/AMDGPU/SIMachineFunctionInfo.cpp11
-rw-r--r--lib/Target/AMDGPU/SIMachineFunctionInfo.h14
-rw-r--r--lib/Target/AMDGPU/SIPeepholeSDWA.cpp100
-rw-r--r--lib/Target/AMDGPU/SIRegisterInfo.cpp40
-rw-r--r--lib/Target/AMDGPU/SIRegisterInfo.h7
-rw-r--r--lib/Target/AMDGPU/SIShrinkInstructions.cpp2
-rw-r--r--lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp21
-rw-r--r--lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h3
-rw-r--r--lib/Target/AMDGPU/VOP1Instructions.td16
-rw-r--r--lib/Target/AMDGPU/VOP2Instructions.td68
-rw-r--r--lib/Target/AMDGPU/VOPCInstructions.td28
-rw-r--r--lib/Target/AMDGPU/VOPInstructions.td88
-rw-r--r--lib/Target/ARM/ARM.td3
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.cpp3
-rw-r--r--lib/Target/ARM/ARMBaseInstrInfo.cpp8
-rw-r--r--lib/Target/ARM/ARMISelLowering.cpp54
-rw-r--r--lib/Target/ARM/ARMISelLowering.h2
-rw-r--r--lib/Target/ARM/ARMInstrThumb2.td10
-rw-r--r--lib/Target/ARM/ARMInstructionSelector.cpp105
-rw-r--r--lib/Target/ARM/ARMLegalizerInfo.cpp6
-rw-r--r--lib/Target/ARM/ARMMacroFusion.cpp57
-rw-r--r--lib/Target/ARM/ARMMacroFusion.h24
-rw-r--r--lib/Target/ARM/ARMRegisterBankInfo.cpp10
-rw-r--r--lib/Target/ARM/ARMSubtarget.h8
-rw-r--r--lib/Target/ARM/ARMTargetMachine.cpp7
-rw-r--r--lib/Target/ARM/AsmParser/ARMAsmParser.cpp66
-rw-r--r--lib/Target/ARM/CMakeLists.txt1
-rw-r--r--lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp63
-rw-r--r--lib/Target/ARM/MCTargetDesc/ARMAsmBackend.h14
-rw-r--r--lib/Target/ARM/MCTargetDesc/ARMWinCOFFObjectWriter.cpp7
-rw-r--r--lib/Target/BPF/BPFISelDAGToDAG.cpp30
-rw-r--r--lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp12
-rw-r--r--lib/Target/Hexagon/HexagonExpandCondsets.cpp15
-rw-r--r--lib/Target/Hexagon/HexagonFrameLowering.cpp61
-rw-r--r--lib/Target/Hexagon/HexagonGenMux.cpp86
-rw-r--r--lib/Target/Hexagon/HexagonInstrInfo.cpp10
-rw-r--r--lib/Target/Hexagon/HexagonNewValueJump.cpp2
-rw-r--r--lib/Target/Hexagon/HexagonPeephole.cpp54
-rw-r--r--lib/Target/Hexagon/HexagonSubtarget.cpp32
-rw-r--r--lib/Target/Hexagon/HexagonSubtarget.h22
-rw-r--r--lib/Target/Hexagon/HexagonTargetMachine.cpp1
-rw-r--r--lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp18
-rw-r--r--lib/Target/Hexagon/MCTargetDesc/HexagonMCDuplexInfo.cpp53
-rw-r--r--lib/Target/Lanai/MCTargetDesc/LanaiAsmBackend.cpp12
-rw-r--r--lib/Target/MSP430/MSP430TargetMachine.cpp8
-rw-r--r--lib/Target/Mips/AsmParser/MipsAsmParser.cpp24
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp8
-rw-r--r--lib/Target/Mips/MCTargetDesc/MipsAsmBackend.h5
-rw-r--r--lib/Target/Mips/Mips32r6InstrInfo.td6
-rw-r--r--lib/Target/Mips/MipsISelLowering.cpp5
-rw-r--r--lib/Target/Mips/MipsLongBranch.cpp12
-rw-r--r--lib/Target/Mips/MipsSEISelLowering.cpp18
-rw-r--r--lib/Target/PowerPC/MCTargetDesc/PPCAsmBackend.cpp11
-rw-r--r--lib/Target/PowerPC/PPC.h1
-rw-r--r--lib/Target/PowerPC/PPCFrameLowering.cpp2
-rw-r--r--lib/Target/PowerPC/PPCISelLowering.cpp11
-rw-r--r--lib/Target/PowerPC/PPCInstr64Bit.td8
-rw-r--r--lib/Target/PowerPC/PPCInstrInfo.cpp23
-rw-r--r--lib/Target/PowerPC/PPCInstrInfo.h2
-rw-r--r--lib/Target/PowerPC/PPCRegisterInfo.cpp15
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.cpp72
-rw-r--r--lib/Target/PowerPC/PPCTargetMachine.h25
-rw-r--r--lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp12
-rw-r--r--lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp12
-rw-r--r--lib/Target/Sparc/SparcTargetObjectFile.cpp6
-rw-r--r--lib/Target/Sparc/SparcTargetObjectFile.h2
-rw-r--r--lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp15
-rw-r--r--lib/Target/SystemZ/SystemZFrameLowering.cpp17
-rw-r--r--lib/Target/SystemZ/SystemZISelLowering.cpp15
-rw-r--r--lib/Target/SystemZ/SystemZISelLowering.h6
-rw-r--r--lib/Target/SystemZ/SystemZInstrInfo.td11
-rw-r--r--lib/Target/SystemZ/SystemZMachineScheduler.cpp2
-rw-r--r--lib/Target/SystemZ/SystemZMachineScheduler.h2
-rw-r--r--lib/Target/SystemZ/SystemZOperators.td2
-rw-r--r--lib/Target/SystemZ/SystemZTargetMachine.h2
-rw-r--r--lib/Target/WebAssembly/MCTargetDesc/WebAssemblyAsmBackend.cpp30
-rw-r--r--lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp18
-rw-r--r--lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp2
-rw-r--r--lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h3
-rw-r--r--lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp2
-rw-r--r--lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp7
-rw-r--r--lib/Target/WebAssembly/WebAssemblyFastISel.cpp20
-rw-r--r--lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp29
-rw-r--r--lib/Target/WebAssembly/WebAssemblyRegStackify.cpp32
-rw-r--r--lib/Target/X86/AsmParser/X86AsmParser.cpp3
-rw-r--r--lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp8
-rw-r--r--lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp3
-rw-r--r--lib/Target/X86/MCTargetDesc/X86WinCOFFObjectWriter.cpp17
-rw-r--r--lib/Target/X86/X86FrameLowering.cpp37
-rw-r--r--lib/Target/X86/X86ISelDAGToDAG.cpp28
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp190
-rw-r--r--lib/Target/X86/X86ISelLowering.h26
-rw-r--r--lib/Target/X86/X86InstrAVX512.td26
-rw-r--r--lib/Target/X86/X86InstrFragmentsSIMD.td24
-rw-r--r--lib/Target/X86/X86InstrSSE.td2
-rw-r--r--lib/Target/X86/X86InstructionSelector.cpp300
-rw-r--r--lib/Target/X86/X86InterleavedAccess.cpp125
-rw-r--r--lib/Target/X86/X86IntrinsicsInfo.h24
-rw-r--r--lib/Target/X86/X86LegalizerInfo.cpp32
-rw-r--r--lib/Target/X86/X86MacroFusion.cpp101
-rw-r--r--lib/Target/X86/X86MacroFusion.h11
-rw-r--r--lib/Target/X86/X86TargetMachine.cpp2
-rw-r--r--lib/Target/X86/X86TargetObjectFile.cpp6
-rw-r--r--lib/Target/X86/X86TargetObjectFile.h5
-rw-r--r--lib/Target/X86/X86TargetTransformInfo.cpp129
-rw-r--r--lib/Target/X86/X86TargetTransformInfo.h7
-rw-r--r--lib/Testing/Support/LLVMBuild.txt1
-rw-r--r--lib/ToolDrivers/llvm-lib/LibDriver.cpp10
-rw-r--r--lib/Transforms/IPO/PassManagerBuilder.cpp13
-rw-r--r--lib/Transforms/IPO/SampleProfile.cpp3
-rw-r--r--lib/Transforms/InstCombine/InstCombineAddSub.cpp27
-rw-r--r--lib/Transforms/InstCombine/InstCombineAndOrXor.cpp126
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp46
-rw-r--r--lib/Transforms/InstCombine/InstCombineCasts.cpp12
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp99
-rw-r--r--lib/Transforms/InstCombine/InstCombineInternal.h27
-rw-r--r--lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp43
-rw-r--r--lib/Transforms/InstCombine/InstCombineSelect.cpp63
-rw-r--r--lib/Transforms/InstCombine/InstCombineShifts.cpp3
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp14
-rw-r--r--lib/Transforms/Instrumentation/IndirectCallPromotion.cpp7
-rw-r--r--lib/Transforms/Instrumentation/InstrProfiling.cpp230
-rw-r--r--lib/Transforms/Instrumentation/PGOInstrumentation.cpp2
-rw-r--r--lib/Transforms/Scalar/CMakeLists.txt1
-rw-r--r--lib/Transforms/Scalar/CorrelatedValuePropagation.cpp5
-rw-r--r--lib/Transforms/Scalar/GVN.cpp188
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp100
-rw-r--r--lib/Transforms/Scalar/LoadCombine.cpp295
-rw-r--r--lib/Transforms/Scalar/LoopDeletion.cpp53
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp2
-rw-r--r--lib/Transforms/Scalar/NewGVN.cpp50
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp110
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp15
-rw-r--r--lib/Transforms/Scalar/SROA.cpp15
-rw-r--r--lib/Transforms/Scalar/Scalar.cpp1
-rw-r--r--lib/Transforms/Scalar/TailRecursionElimination.cpp52
-rw-r--r--lib/Transforms/Utils/BuildLibCalls.cpp1
-rw-r--r--lib/Transforms/Utils/Local.cpp54
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp83
-rw-r--r--lib/Transforms/Utils/LoopUnrollRuntime.cpp46
-rw-r--r--lib/Transforms/Utils/LoopUtils.cpp68
-rw-r--r--lib/Transforms/Vectorize/LoopVectorize.cpp47
-rw-r--r--lib/Transforms/Vectorize/SLPVectorizer.cpp6
-rw-r--r--test/Analysis/BasicAA/2007-08-01-NoAliasAndGEP.ll4
-rw-r--r--test/Analysis/BasicAA/2010-09-15-GEP-SignedArithmetic.ll2
-rw-r--r--test/Analysis/BasicAA/bug.23540.ll2
-rw-r--r--test/Analysis/BasicAA/bug.23626.ll14
-rw-r--r--test/Analysis/BasicAA/constant-over-index.ll2
-rw-r--r--test/Analysis/BasicAA/fallback-mayalias.ll23
-rw-r--r--test/Analysis/BasicAA/q.bad.ll14
-rw-r--r--test/Analysis/BasicAA/returned.ll16
-rw-r--r--test/Analysis/BasicAA/sequential-gep.ll6
-rw-r--r--test/Analysis/BasicAA/struct-geps.ll78
-rw-r--r--test/Analysis/BasicAA/zext.ll8
-rw-r--r--test/Analysis/CostModel/X86/arith.ll1002
-rw-r--r--test/Analysis/CostModel/X86/interleaved-load-i8.ll98
-rw-r--r--test/Analysis/CostModel/X86/interleaved-store-i8.ll85
-rw-r--r--test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll87
-rw-r--r--test/Analysis/TypeBasedAliasAnalysis/dynamic-indices.ll19
-rw-r--r--test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll36
-rw-r--r--test/CodeGen/AArch64/GlobalISel/call-translator.ll2
-rw-r--r--test/CodeGen/AArch64/GlobalISel/legalize-combines.mir50
-rw-r--r--test/CodeGen/AArch64/GlobalISel/no-regclass.mir4
-rw-r--r--test/CodeGen/AArch64/GlobalISel/select-bitcast.mir4
-rw-r--r--test/CodeGen/AArch64/arm64-early-ifcvt.ll2
-rw-r--r--test/CodeGen/AArch64/arm64-neon-copy.ll2
-rw-r--r--test/CodeGen/AArch64/arm64-shrink-v1i64.ll2
-rw-r--r--test/CodeGen/AArch64/arm64-shrink-wrapping.ll24
-rw-r--r--test/CodeGen/AArch64/atomic-ops-lse.ll683
-rw-r--r--test/CodeGen/AArch64/cond-br-tuning.ll169
-rw-r--r--test/CodeGen/AArch64/ldst-opt.ll60
-rw-r--r--test/CodeGen/AArch64/ldst-opt.mir39
-rw-r--r--test/CodeGen/AArch64/mergestores_noimplicitfloat.ll23
-rw-r--r--test/CodeGen/AArch64/misched-fusion.ll4
-rw-r--r--test/CodeGen/AArch64/reg-scavenge-frame.mir42
-rw-r--r--test/CodeGen/AArch64/stack-guard-remat-bitcast.ll4
-rw-r--r--test/CodeGen/AArch64/swiftself-scavenger.ll2
-rw-r--r--test/CodeGen/AArch64/tbz-tbnz.ll2
-rw-r--r--test/CodeGen/AArch64/thread-pointer.ll4
-rw-r--r--test/CodeGen/AArch64/xray-attribute-instrumentation.ll4
-rw-r--r--test/CodeGen/AArch64/xray-tail-call-sled.ll22
-rw-r--r--test/CodeGen/AMDGPU/GlobalISel/legalize-and.mir22
-rw-r--r--test/CodeGen/AMDGPU/GlobalISel/legalize-bitcast.mir23
-rw-r--r--test/CodeGen/AMDGPU/GlobalISel/legalize-shl.mir18
-rw-r--r--test/CodeGen/AMDGPU/attr-amdgpu-num-sgpr.ll77
-rw-r--r--test/CodeGen/AMDGPU/branch-relaxation.ll10
-rw-r--r--test/CodeGen/AMDGPU/callee-frame-setup.ll27
-rw-r--r--test/CodeGen/AMDGPU/code-object-metadata-kernel-debug-props.ll4
-rw-r--r--test/CodeGen/AMDGPU/combine-cond-add-sub.ll159
-rw-r--r--test/CodeGen/AMDGPU/constant-fold-imm-immreg.mir27
-rw-r--r--test/CodeGen/AMDGPU/fneg.f16.ll7
-rw-r--r--test/CodeGen/AMDGPU/fold-operands-order.mir47
-rw-r--r--test/CodeGen/AMDGPU/fpext.f16.ll15
-rw-r--r--test/CodeGen/AMDGPU/frame-index-elimination.ll68
-rw-r--r--test/CodeGen/AMDGPU/infer-addrpace-pipeline.ll10
-rw-r--r--test/CodeGen/AMDGPU/llvm.SI.tbuffer.store.ll38
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.implicit.buffer.ptr.hsa.ll24
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.implicit.buffer.ptr.ll35
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.mqsad.pk.u16.u8.ll2
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.qsad.pk.u16.u8.ll2
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.tbuffer.load.ll109
-rw-r--r--test/CodeGen/AMDGPU/llvm.amdgcn.tbuffer.store.ll110
-rw-r--r--test/CodeGen/AMDGPU/llvm.rint.f16.ll4
-rw-r--r--test/CodeGen/AMDGPU/merge-store-crash.ll4
-rw-r--r--test/CodeGen/AMDGPU/merge-store-usedef.ll4
-rw-r--r--test/CodeGen/AMDGPU/mubuf.ll8
-rw-r--r--test/CodeGen/AMDGPU/opt-sgpr-to-vgpr-copy.mir341
-rw-r--r--test/CodeGen/AMDGPU/scheduler-subrange-crash.ll18
-rw-r--r--test/CodeGen/AMDGPU/sdwa-gfx9.mir88
-rw-r--r--test/CodeGen/AMDGPU/sdwa-peephole.ll168
-rw-r--r--test/CodeGen/AMDGPU/sdwa-scalar-ops.mir19
-rw-r--r--test/CodeGen/AMDGPU/sdwa-vop2-64bit.mir61
-rw-r--r--test/CodeGen/AMDGPU/shrink-carry.mir101
-rw-r--r--test/CodeGen/AMDGPU/si-triv-disjoint-mem-access.ll9
-rw-r--r--test/CodeGen/AMDGPU/sint_to_fp.i64.ll4
-rw-r--r--test/CodeGen/AMDGPU/spill-m0.ll8
-rw-r--r--test/CodeGen/AMDGPU/uint_to_fp.i64.ll4
-rw-r--r--test/CodeGen/ARM/2012-08-30-select.ll7
-rw-r--r--test/CodeGen/ARM/GlobalISel/arm-instruction-select-cmp.mir373
-rw-r--r--test/CodeGen/ARM/GlobalISel/arm-irtranslator.ll7
-rw-r--r--test/CodeGen/ARM/GlobalISel/arm-isel.ll41
-rw-r--r--test/CodeGen/ARM/GlobalISel/arm-legalizer.mir84
-rw-r--r--test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir30
-rw-r--r--test/CodeGen/ARM/alloca-align.ll2
-rw-r--r--test/CodeGen/ARM/constantfp.ll50
-rw-r--r--test/CodeGen/ARM/execute-only-big-stack-frame.ll4
-rw-r--r--test/CodeGen/ARM/fpoffset_overflow.mir12
-rw-r--r--test/CodeGen/ARM/misched-fusion-aes.ll203
-rw-r--r--test/CodeGen/ARM/v6m-umul-with-overflow.ll16
-rw-r--r--test/CodeGen/ARM/vector-promotion.ll4
-rw-r--r--test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll9
-rw-r--r--test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll9
-rw-r--r--test/CodeGen/Generic/llc-start-stop.ll5
-rw-r--r--test/CodeGen/Generic/print-machineinstrs.ll27
-rw-r--r--test/CodeGen/Hexagon/duplex-addi-global-imm.mir22
-rw-r--r--test/CodeGen/Hexagon/expand-condsets-imm.mir22
-rw-r--r--test/CodeGen/Hexagon/mux-kill1.mir (renamed from test/CodeGen/Hexagon/mux-kill.mir)2
-rw-r--r--test/CodeGen/Hexagon/mux-kill2.mir2
-rw-r--r--test/CodeGen/Hexagon/mux-kill3.mir31
-rw-r--r--test/CodeGen/Hexagon/newvaluejump-kill.ll53
-rw-r--r--test/CodeGen/Hexagon/stack-align-reset.ll51
-rw-r--r--test/CodeGen/Hexagon/store-imm-large-stack.ll151
-rw-r--r--test/CodeGen/Hexagon/vec-vararg-align.ll30
-rw-r--r--test/CodeGen/MSP430/Inst16mm.ll2
-rw-r--r--test/CodeGen/MSP430/struct_layout.ll57
-rw-r--r--test/CodeGen/Mips/dins.ll39
-rw-r--r--test/CodeGen/Mips/emergency-spill-slot-near-fp.ll88
-rw-r--r--test/CodeGen/Mips/longbranch.ll40
-rw-r--r--test/CodeGen/Mips/msa/3r_splat.ll21
-rw-r--r--test/CodeGen/PowerPC/2010-02-12-saveCR.ll6
-rw-r--r--test/CodeGen/PowerPC/complex-return.ll2
-rw-r--r--test/CodeGen/PowerPC/dyn-alloca-aligned.ll4
-rw-r--r--test/CodeGen/PowerPC/licm-remat.ll179
-rw-r--r--test/CodeGen/PowerPC/memCmpUsedInZeroEqualityComparison.ll33
-rw-r--r--test/CodeGen/PowerPC/memcpy_dereferenceable.ll74
-rw-r--r--test/CodeGen/PowerPC/scavenging.mir67
-rw-r--r--test/CodeGen/PowerPC/vsx-spill.ll10
-rw-r--r--test/CodeGen/PowerPC/vsx.ll30
-rw-r--r--test/CodeGen/SPARC/constructor.ll29
-rw-r--r--test/CodeGen/SystemZ/frame-21.ll76
-rw-r--r--test/CodeGen/SystemZ/int-cmp-54.ll20
-rw-r--r--test/CodeGen/SystemZ/serialize-01.ll21
-rw-r--r--test/CodeGen/SystemZ/trap-02.ll4
-rw-r--r--test/CodeGen/Thumb/large-stack.ll12
-rw-r--r--test/CodeGen/Thumb2/ifcvt-neon-deprecated.mir54
-rw-r--r--test/CodeGen/Thumb2/ifcvt-neon.ll29
-rw-r--r--test/CodeGen/WebAssembly/byval.ll14
-rw-r--r--test/CodeGen/WebAssembly/offset-fastisel.ll100
-rw-r--r--test/CodeGen/WebAssembly/reg-stackify.ll2
-rw-r--r--test/CodeGen/WebAssembly/stack-alignment.ll24
-rw-r--r--test/CodeGen/WebAssembly/userstack.ll52
-rw-r--r--test/CodeGen/X86/2006-05-11-InstrSched.ll2
-rw-r--r--test/CodeGen/X86/2012-12-06-python27-miscompile.ll23
-rw-r--r--test/CodeGen/X86/GlobalISel/add-scalar.ll34
-rw-r--r--test/CodeGen/X86/GlobalISel/callingconv.ll92
-rw-r--r--test/CodeGen/X86/GlobalISel/ext.ll15
-rw-r--r--test/CodeGen/X86/GlobalISel/legalize-add-v256.mir99
-rw-r--r--test/CodeGen/X86/GlobalISel/legalize-add-v512.mir179
-rw-r--r--test/CodeGen/X86/GlobalISel/legalize-insert-vec256.mir33
-rw-r--r--test/CodeGen/X86/GlobalISel/legalize-insert-vec512.mir63
-rw-r--r--test/CodeGen/X86/GlobalISel/memop-scalar-x32.ll36
-rw-r--r--test/CodeGen/X86/GlobalISel/memop-scalar.ll48
-rw-r--r--test/CodeGen/X86/GlobalISel/select-extract-vec256.mir80
-rw-r--r--test/CodeGen/X86/GlobalISel/select-extract-vec512.mir127
-rw-r--r--test/CodeGen/X86/GlobalISel/select-insert-vec256.mir176
-rw-r--r--test/CodeGen/X86/GlobalISel/select-insert-vec512.mir271
-rw-r--r--test/CodeGen/X86/GlobalISel/select-memop-scalar-x32.mir60
-rw-r--r--test/CodeGen/X86/GlobalISel/select-memop-scalar.mir116
-rw-r--r--test/CodeGen/X86/MergeConsecutiveStores.ll31
-rw-r--r--test/CodeGen/X86/atom-fixup-lea3.ll11
-rw-r--r--test/CodeGen/X86/avg.ll1606
-rw-r--r--test/CodeGen/X86/avx-intrinsics-x86-upgrade.ll9
-rw-r--r--test/CodeGen/X86/avx-intrinsics-x86.ll8
-rw-r--r--test/CodeGen/X86/avx-logic.ll6
-rw-r--r--test/CodeGen/X86/avx-vperm2x128.ll32
-rw-r--r--test/CodeGen/X86/avx2-intrinsics-x86-upgrade.ll3
-rw-r--r--test/CodeGen/X86/avx2-logic.ll28
-rw-r--r--test/CodeGen/X86/avx2-vbroadcast.ll2
-rw-r--r--test/CodeGen/X86/avx512-arith.ll8
-rw-r--r--test/CodeGen/X86/avx512-intrinsics-upgrade.ll372
-rw-r--r--test/CodeGen/X86/avx512-intrinsics.ll388
-rw-r--r--test/CodeGen/X86/avx512-logic.ll24
-rw-r--r--test/CodeGen/X86/avx512-mask-op.ll8
-rw-r--r--test/CodeGen/X86/avx512-round.ll16
-rw-r--r--test/CodeGen/X86/avx512-vec3-crash.ll31
-rw-r--r--test/CodeGen/X86/avx512bw-intrinsics-upgrade.ll2050
-rw-r--r--test/CodeGen/X86/avx512bw-intrinsics.ll656
-rw-r--r--test/CodeGen/X86/avx512bwvl-intrinsics-upgrade.ll853
-rw-r--r--test/CodeGen/X86/avx512bwvl-intrinsics.ll884
-rw-r--r--test/CodeGen/X86/avx512vl-arith.ll14
-rw-r--r--test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll951
-rw-r--r--test/CodeGen/X86/avx512vl-intrinsics.ll780
-rw-r--r--test/CodeGen/X86/avx512vl-logic.ll32
-rw-r--r--test/CodeGen/X86/bitcast-i256.ll26
-rw-r--r--test/CodeGen/X86/clear_upper_vector_element_bits.ll15
-rw-r--r--test/CodeGen/X86/combine-pmuldq.ll110
-rw-r--r--test/CodeGen/X86/constructor.ll2
-rw-r--r--test/CodeGen/X86/extract-store.ll129
-rw-r--r--test/CodeGen/X86/full-lsr.ll10
-rw-r--r--test/CodeGen/X86/hoist-spill.ll2
-rw-r--r--test/CodeGen/X86/implicit-null-checks.mir6
-rw-r--r--test/CodeGen/X86/insertelement-zero.ll33
-rw-r--r--test/CodeGen/X86/insertps-combine.ll6
-rw-r--r--test/CodeGen/X86/jump_sign.ll297
-rw-r--r--test/CodeGen/X86/loop-strength-reduce4.ll15
-rw-r--r--test/CodeGen/X86/machine-cse.ll134
-rw-r--r--test/CodeGen/X86/madd.ll78
-rw-r--r--test/CodeGen/X86/masked-iv-safe.ll16
-rw-r--r--test/CodeGen/X86/masked_gather_scatter.ll69
-rw-r--r--test/CodeGen/X86/memcmp.ll108
-rw-r--r--test/CodeGen/X86/merge-consecutive-stores.ll33
-rw-r--r--test/CodeGen/X86/non-value-mem-operand.mir293
-rw-r--r--test/CodeGen/X86/pr15705.ll48
-rw-r--r--test/CodeGen/X86/pr15981.ll59
-rw-r--r--test/CodeGen/X86/pr33396.ll27
-rw-r--r--test/CodeGen/X86/sbb.ll138
-rw-r--r--test/CodeGen/X86/scavenger.mir29
-rw-r--r--test/CodeGen/X86/select.ll10
-rw-r--r--test/CodeGen/X86/shuffle-vs-trunc-128.ll156
-rw-r--r--test/CodeGen/X86/shuffle-vs-trunc-256.ll341
-rw-r--r--test/CodeGen/X86/splat-for-size.ll20
-rw-r--r--test/CodeGen/X86/sse-scalar-fp-arith.ll10
-rw-r--r--test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll3
-rw-r--r--test/CodeGen/X86/sse2.ll438
-rw-r--r--test/CodeGen/X86/sse3.ll202
-rw-r--r--test/CodeGen/X86/stack-probe-red-zone.ll21
-rw-r--r--test/CodeGen/X86/stack-probes.ll29
-rw-r--r--test/CodeGen/X86/vec_ctbits.ll38
-rw-r--r--test/CodeGen/X86/vector-blend.ll74
-rw-r--r--test/CodeGen/X86/vector-interleave.ll12
-rw-r--r--test/CodeGen/X86/vector-merge-store-fp-constants.ll32
-rw-r--r--test/CodeGen/X86/vector-shuffle-128-v16.ll15
-rw-r--r--test/CodeGen/X86/vector-shuffle-128-v2.ll17
-rw-r--r--test/CodeGen/X86/vector-shuffle-128-v4.ll17
-rw-r--r--test/CodeGen/X86/vector-shuffle-128-v8.ll15
-rw-r--r--test/CodeGen/X86/vector-shuffle-256-v16.ll8
-rw-r--r--test/CodeGen/X86/vector-shuffle-256-v32.ll8
-rw-r--r--test/CodeGen/X86/vector-shuffle-256-v4.ll8
-rw-r--r--test/CodeGen/X86/vector-shuffle-256-v8.ll8
-rw-r--r--test/CodeGen/X86/vector-shuffle-masked.ll2
-rw-r--r--test/CodeGen/X86/vector-shuffle-sse1.ll18
-rw-r--r--test/CodeGen/X86/vector-shuffle-v1.ll6
-rw-r--r--test/CodeGen/X86/vector-shuffle-v48.ll57
-rw-r--r--test/CodeGen/X86/vector-shuffle-variable-128.ll10
-rw-r--r--test/CodeGen/X86/vector-shuffle-variable-256.ll5
-rw-r--r--test/CodeGen/X86/vector-tzcnt-128.ll758
-rw-r--r--test/CodeGen/X86/vector-tzcnt-256.ll162
-rw-r--r--test/CodeGen/X86/vector-tzcnt-512.ll108
-rw-r--r--test/CodeGen/X86/vector-zmov.ll12
-rw-r--r--test/CodeGen/X86/widen_arith-1.ll76
-rw-r--r--test/CodeGen/X86/widen_arith-2.ll104
-rw-r--r--test/CodeGen/X86/widen_arith-3.ll88
-rw-r--r--test/CodeGen/X86/widen_arith-4.ll83
-rw-r--r--test/CodeGen/X86/widen_arith-5.ll83
-rw-r--r--test/CodeGen/X86/widen_arith-6.ll88
-rw-r--r--test/CodeGen/X86/widen_cast-1.ll104
-rw-r--r--test/CodeGen/X86/widen_cast-2.ll77
-rw-r--r--test/CodeGen/X86/widen_cast-3.ll19
-rw-r--r--test/CodeGen/X86/widen_cast-4.ll169
-rw-r--r--test/CodeGen/X86/widen_conv-1.ll12
-rw-r--r--test/CodeGen/X86/x86-interleaved-access.ll151
-rw-r--r--test/CodeGen/X86/xray-attribute-instrumentation.ll18
-rw-r--r--test/CodeGen/X86/xray-custom-log.ll2
-rw-r--r--test/CodeGen/X86/xray-log-args.ll4
-rw-r--r--test/CodeGen/X86/xray-tail-call-sled.ll18
-rw-r--r--test/DebugInfo/COFF/globals.ll38
-rw-r--r--test/DebugInfo/Generic/sugared-constants.ll30
-rw-r--r--test/DebugInfo/Inputs/dwarfdump-str-offsets.s59
-rw-r--r--test/DebugInfo/Inputs/dwarfdump-str-offsets.x86_64.obin4000 -> 4344 bytes
-rw-r--r--test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir249
-rw-r--r--test/DebugInfo/MIR/X86/bit-piece-dh.mir10
-rw-r--r--test/DebugInfo/PDB/dbi-bytes.test59
-rw-r--r--test/DebugInfo/PDB/module-bytes.test85
-rw-r--r--test/DebugInfo/PDB/pdb-yaml-symbols.test3
-rw-r--r--test/DebugInfo/PDB/pdbdump-headers.test61
-rw-r--r--test/DebugInfo/PDB/pdbdump-merge-ids-and-types.test4
-rw-r--r--test/DebugInfo/PDB/pdbdump-mergeids.test4
-rw-r--r--test/DebugInfo/PDB/pdbdump-mergetypes.test2
-rw-r--r--test/DebugInfo/PDB/pdbdump-raw-blocks.test17
-rw-r--r--test/DebugInfo/PDB/pdbdump-raw-bytes.test25
-rw-r--r--test/DebugInfo/PDB/pdbdump-raw-stream.test67
-rw-r--r--test/DebugInfo/PDB/pdbdump-readwrite.test4
-rw-r--r--test/DebugInfo/PDB/pdbdump-yaml-types.test2
-rw-r--r--test/DebugInfo/PDB/tpi-bytes.test27
-rw-r--r--test/DebugInfo/X86/dbg-merge-loc-entry.ll2
-rw-r--r--test/DebugInfo/X86/inlined-formal-parameter.ll14
-rw-r--r--test/DebugInfo/X86/parameters.ll13
-rw-r--r--test/DebugInfo/X86/partial-constant.ll82
-rw-r--r--test/DebugInfo/X86/pieces-3.ll9
-rw-r--r--test/DebugInfo/X86/reference-argument.ll10
-rw-r--r--test/DebugInfo/X86/this-stack_value.ll4
-rw-r--r--test/DebugInfo/dwarfdump-str-offsets.test36
-rw-r--r--test/MC/AArch64/label-arithmetic-diags-darwin.s4
-rw-r--r--test/MC/AMDGPU/flat-global.s87
-rw-r--r--test/MC/AMDGPU/gfx7_asm_all.s54199
-rw-r--r--test/MC/AMDGPU/gfx8_asm_all.s59352
-rw-r--r--test/MC/AMDGPU/gfx9_asm_all.s80057
-rw-r--r--test/MC/AMDGPU/mtbuf.s36
-rw-r--r--test/MC/AMDGPU/regression/bug28168.s12
-rw-r--r--test/MC/AMDGPU/vop3-errs.s24
-rw-r--r--test/MC/AMDGPU/vop3.s6
-rw-r--r--test/MC/ARM/basic-thumb2-instructions.s16
-rw-r--r--test/MC/ARM/elf-movt.s58
-rw-r--r--test/MC/ARM/thumb-branches.s36
-rw-r--r--test/MC/ARM/thumb2-beq-fixup.s39
-rw-r--r--test/MC/AsmParser/negativ_altmacro_expression.s2
-rw-r--r--test/MC/COFF/bad-expr.s2
-rw-r--r--test/MC/COFF/cross-section-relative-err.s12
-rw-r--r--test/MC/COFF/cross-section-relative.s109
-rw-r--r--test/MC/COFF/diff.s6
-rw-r--r--test/MC/COFF/secidx-diagnostic.s10
-rw-r--r--test/MC/COFF/secrel32-undef.s30
-rw-r--r--test/MC/Disassembler/AMDGPU/gfx8_dasm_all.txt61128
-rw-r--r--test/MC/Disassembler/AMDGPU/gfx9_dasm_all.txt88936
-rw-r--r--test/MC/Disassembler/AMDGPU/mtbuf_vi.txt22
-rw-r--r--test/MC/Disassembler/Mips/mips32r6/valid-mips32r6-el.txt2
-rw-r--r--test/MC/Disassembler/Mips/mips32r6/valid-mips32r6.txt2
-rw-r--r--test/MC/Disassembler/Mips/mips64r6/valid-mips64r6-el.txt4
-rw-r--r--test/MC/Disassembler/Mips/mips64r6/valid-mips64r6.txt4
-rw-r--r--test/MC/ELF/bad-expr.s6
-rw-r--r--test/MC/ELF/bad-expr2.s7
-rw-r--r--test/MC/Hexagon/duplex-addi-global-imm.s15
-rw-r--r--test/MC/Mips/mips-rdata.s13
-rw-r--r--test/MC/Mips/mips-register-names-o32.s1
-rw-r--r--test/MC/Mips/mips32r6/valid.s2
-rw-r--r--test/MC/Mips/mips64-register-names-n32-n64.s1
-rw-r--r--test/MC/Mips/mips64-register-names-o32.s1
-rw-r--r--test/MC/Mips/mips64r6/valid.s4
-rw-r--r--test/MC/WebAssembly/func-address.ll5
-rw-r--r--test/MC/WebAssembly/stack-ptr.ll21
-rw-r--r--test/MC/X86/macho-reloc-errors-x86_64.s2
-rw-r--r--test/Object/obj2yaml.test2
-rw-r--r--test/ObjectYAML/wasm/header_invalid_version.yaml2
-rw-r--r--test/ObjectYAML/wasm/weak_symbols.yaml40
-rw-r--r--test/TableGen/GlobalISelEmitter.td26
-rw-r--r--test/Transforms/CodeGenPrepare/X86/memcmp.ll156
-rw-r--r--test/Transforms/CorrelatedValuePropagation/add.ll95
-rw-r--r--test/Transforms/GVN/PRE/phi-translate-2.ll131
-rw-r--r--test/Transforms/GVN/PRE/pre-gep-load.ll2
-rw-r--r--test/Transforms/GVN/PRE/pre-load.ll6
-rw-r--r--test/Transforms/IndVarSimplify/huge_muls.ll87
-rw-r--r--test/Transforms/InferFunctionAttrs/annotate.ll7
-rw-r--r--test/Transforms/Inline/AArch64/switch.ll37
-rw-r--r--test/Transforms/Inline/inline-probe-stack.ll20
-rw-r--r--test/Transforms/Inline/inline-stack-probe-size.ll29
-rw-r--r--test/Transforms/InstCombine/add.ll12
-rw-r--r--test/Transforms/InstCombine/and-or-not.ll48
-rw-r--r--test/Transforms/InstCombine/bitcast-bigendian.ll18
-rw-r--r--test/Transforms/InstCombine/bitcast.ll26
-rw-r--r--test/Transforms/InstCombine/compare-3way.ll395
-rw-r--r--test/Transforms/InstCombine/ctpop.ll39
-rw-r--r--test/Transforms/InstCombine/early_constfold_changes_IR.ll20
-rw-r--r--test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll31
-rw-r--r--test/Transforms/InstCombine/icmp-xor-signbit.ll21
-rw-r--r--test/Transforms/InstCombine/intrinsics.ll41
-rw-r--r--test/Transforms/InstCombine/logical-select.ll4
-rw-r--r--test/Transforms/InstCombine/memcpy-from-global.ll31
-rw-r--r--test/Transforms/InstCombine/or-xor.ll4
-rw-r--r--test/Transforms/InstCombine/phi-select-constant.ll29
-rw-r--r--test/Transforms/InstCombine/pr33453.ll15
-rw-r--r--test/Transforms/InstCombine/select-with-bitwise-ops.ll78
-rw-r--r--test/Transforms/InstCombine/select.ll4
-rw-r--r--test/Transforms/InstCombine/set.ll22
-rw-r--r--test/Transforms/InstCombine/xor2.ll4
-rw-r--r--test/Transforms/InterleavedAccess/X86/interleaved-accesses-64bits-avx.ll73
-rw-r--r--test/Transforms/InterleavedAccess/X86/interleavedStore.ll17
-rw-r--r--test/Transforms/LICM/strlen.ll19
-rw-r--r--test/Transforms/LoadCombine/deadcode.ll39
-rw-r--r--test/Transforms/LoadCombine/load-combine-aa.ll63
-rw-r--r--test/Transforms/LoadCombine/load-combine-assume.ll44
-rw-r--r--test/Transforms/LoadCombine/load-combine-negativegep.ll19
-rw-r--r--test/Transforms/LoadCombine/load-combine.ll190
-rw-r--r--test/Transforms/LoopDeletion/unreachable-loops.ll76
-rwxr-xr-xtest/Transforms/LoopRotate/catchret.ll41
-rw-r--r--test/Transforms/LoopSimplify/basictest.ll243
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/bin_power.ll264
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/canonical.ll2
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll4
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/lsr-expand-quadratic.ll12
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/lsr-insns-1.ll4
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/lsr-insns-2.ll4
-rw-r--r--test/Transforms/LoopStrengthReduce/X86/nested-loop.ll22
-rw-r--r--test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll1
-rw-r--r--test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll1
-rw-r--r--test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll1
-rw-r--r--test/Transforms/LoopVectorize/AMDGPU/packed-math.ll34
-rw-r--r--test/Transforms/LoopVectorize/X86/small-size.ll26
-rw-r--r--test/Transforms/LoopVectorize/tripcount.ll91
-rw-r--r--test/Transforms/LowerTypeTests/export-icall.ll9
-rw-r--r--test/Transforms/NewGVN/pr33461.ll36
-rw-r--r--test/Transforms/PGOProfile/counter_promo.ll68
-rw-r--r--test/Transforms/PGOProfile/counter_promo_exit_merge.ll74
-rw-r--r--test/Transforms/PGOProfile/counter_promo_mexits.ll80
-rw-r--r--test/Transforms/PGOProfile/memop_size_from_strlen.ll14
-rw-r--r--test/Transforms/Reassociate/fast-ReassociateVector.ll18
-rw-r--r--test/Transforms/Reassociate/xor_reassoc.ll101
-rw-r--r--test/Transforms/SLPVectorizer/AMDGPU/packed-math.ll195
-rw-r--r--test/Transforms/SLPVectorizer/AMDGPU/simplebb.ll70
-rw-r--r--test/Transforms/SROA/non-integral-pointers.ll46
-rw-r--r--test/Transforms/SampleProfile/Inputs/einline.prof3
-rw-r--r--test/Transforms/SampleProfile/early-inline.ll16
-rw-r--r--test/Transforms/TailCallElim/reorder_load.ll27
-rw-r--r--test/tools/llvm-dwarfdump/X86/apple_names_verify_buckets.s2
-rw-r--r--test/tools/llvm-dwarfdump/X86/no_apple_names_verify_buckets.s174
-rwxr-xr-xtest/tools/llvm-nm/X86/Inputs/Strip-ST.dylib.macho-x86_64bin0 -> 8344 bytes
-rw-r--r--test/tools/llvm-nm/X86/dyldinfo.test18
-rw-r--r--test/tools/llvm-nm/wasm/exports.yaml11
-rw-r--r--test/tools/llvm-nm/wasm/weak-symbols.yaml49
-rwxr-xr-xtest/tools/llvm-objdump/AArch64/Inputs/kextbundle.macho-aarch64bin0 -> 49260 bytes
-rw-r--r--test/tools/llvm-objdump/AArch64/macho-kextbundle.test9
-rwxr-xr-xtest/tools/llvm-objdump/X86/Inputs/kextbundle.macho-x86_64bin0 -> 4152 bytes
-rw-r--r--test/tools/llvm-objdump/X86/macho-disassembly-kextbundle.test9
-rw-r--r--test/tools/llvm-objdump/X86/macho-info-plist.test4
-rw-r--r--test/tools/llvm-objdump/X86/macho-objc-meta-data.test4
-rw-r--r--test/tools/llvm-objdump/macho-exports-trie.test10
-rw-r--r--test/tools/llvm-readobj/Inputs/coff-load-config-data-end.exebin0 -> 1536 bytes
-rw-r--r--test/tools/llvm-readobj/Inputs/coff-load-config-x64.dllbin0 -> 9728 bytes
-rw-r--r--test/tools/llvm-readobj/Inputs/coff-load-config-x86.dllbin0 -> 8704 bytes
-rw-r--r--test/tools/llvm-readobj/coff-load-config.test93
-rw-r--r--test/tools/obj2yaml/invalid_input_file.test4
-rw-r--r--tools/bugpoint/CMakeLists.txt1
-rw-r--r--tools/bugpoint/LLVMBuild.txt1
-rw-r--r--tools/bugpoint/bugpoint.cpp8
-rw-r--r--tools/dsymutil/DwarfLinker.cpp14
-rw-r--r--tools/lli/OrcLazyJIT.cpp80
-rw-r--r--tools/lli/OrcLazyJIT.h135
-rw-r--r--tools/llvm-cvtres/llvm-cvtres.cpp70
-rw-r--r--tools/llvm-cvtres/llvm-cvtres.h17
-rw-r--r--tools/llvm-dwp/llvm-dwp.cpp4
-rw-r--r--tools/llvm-nm/llvm-nm.cpp597
-rw-r--r--tools/llvm-objdump/MachODump.cpp82
-rw-r--r--tools/llvm-pdbutil/Analyze.cpp28
-rw-r--r--tools/llvm-pdbutil/BytesOutputStyle.cpp501
-rw-r--r--tools/llvm-pdbutil/BytesOutputStyle.h67
-rw-r--r--tools/llvm-pdbutil/CMakeLists.txt4
-rw-r--r--tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp59
-rw-r--r--tools/llvm-pdbutil/CompactTypeDumpVisitor.h49
-rw-r--r--tools/llvm-pdbutil/Diff.cpp273
-rw-r--r--tools/llvm-pdbutil/DumpOutputStyle.cpp (renamed from tools/llvm-pdbutil/RawOutputStyle.cpp)229
-rw-r--r--tools/llvm-pdbutil/DumpOutputStyle.h (renamed from tools/llvm-pdbutil/RawOutputStyle.h)14
-rw-r--r--tools/llvm-pdbutil/LinePrinter.cpp140
-rw-r--r--tools/llvm-pdbutil/LinePrinter.h15
-rw-r--r--tools/llvm-pdbutil/MinimalSymbolDumper.cpp16
-rw-r--r--tools/llvm-pdbutil/llvm-pdbutil.cpp332
-rw-r--r--tools/llvm-pdbutil/llvm-pdbutil.h42
-rw-r--r--tools/llvm-profdata/llvm-profdata.cpp8
-rw-r--r--tools/llvm-readobj/COFFDumper.cpp140
-rw-r--r--tools/llvm-readobj/ObjDumper.h1
-rw-r--r--tools/llvm-readobj/llvm-readobj.cpp7
-rw-r--r--tools/llvm-stress/llvm-stress.cpp87
-rw-r--r--tools/obj2yaml/obj2yaml.cpp25
-rw-r--r--tools/obj2yaml/wasm2yaml.cpp73
-rw-r--r--tools/yaml2obj/yaml2wasm.cpp39
-rw-r--r--unittests/ADT/StringExtrasTest.cpp20
-rw-r--r--unittests/ADT/TripleTest.cpp6
-rw-r--r--unittests/Analysis/AliasSetTrackerTest.cpp87
-rw-r--r--unittests/Analysis/CMakeLists.txt1
-rw-r--r--unittests/BinaryFormat/TestFileMagic.cpp3
-rw-r--r--unittests/DebugInfo/CodeView/RandomAccessVisitorTest.cpp52
-rw-r--r--unittests/DebugInfo/CodeView/TypeIndexDiscoveryTest.cpp87
-rw-r--r--unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp29
-rw-r--r--unittests/DebugInfo/PDB/PDBApiTest.cpp4
-rw-r--r--unittests/ExecutionEngine/Orc/LazyEmittingLayerTest.cpp8
-rw-r--r--unittests/ExecutionEngine/Orc/ObjectTransformLayerTest.cpp177
-rw-r--r--unittests/ExecutionEngine/Orc/OrcCAPITest.cpp13
-rw-r--r--unittests/ExecutionEngine/Orc/OrcTestCommon.h48
-rw-r--r--unittests/ExecutionEngine/Orc/RTDyldObjectLinkingLayerTest.cpp56
-rw-r--r--unittests/Option/OptionParsingTest.cpp13
-rw-r--r--unittests/ProfileData/CoverageMappingTest.cpp55
-rw-r--r--unittests/ProfileData/InstrProfTest.cpp16
-rw-r--r--unittests/Support/CachePruningTest.cpp34
-rw-r--r--unittests/Support/CommandLineTest.cpp6
-rw-r--r--unittests/Support/ErrorTest.cpp4
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.cpp30
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.h12
-rw-r--r--utils/TableGen/DAGISelMatcherGen.cpp6
-rw-r--r--utils/TableGen/GlobalISelEmitter.cpp120
-rw-r--r--utils/TableGen/OptParserEmitter.cpp10
-rwxr-xr-xutils/opt-viewer/opt-stats.py6
-rwxr-xr-xutils/opt-viewer/opt-viewer.py4
-rw-r--r--utils/opt-viewer/optrecord.py24
-rwxr-xr-xutils/release/test-release.sh8
982 files changed, 295700 insertions, 97897 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 431785d3dd0c..9cdc688d42b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,7 @@ if(CMAKE_HOST_APPLE AND APPLE)
set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")
endif()
endif()
-
+
foreach(lang ${languages})
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
"${CMAKE_LIBTOOL} -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> \
@@ -570,6 +570,10 @@ if (LLVM_BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()
+# Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
+set(LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank.")
+mark_as_advanced(LLVM_TARGET_TRIPLE_ENV)
+
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
@@ -800,7 +804,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
+ # special hack for Solaris to handle crazy system sys/regset.h
+ include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
# Make sure we don't get -rdynamic in every binary. For those that need it,
diff --git a/CODE_OWNERS.TXT b/CODE_OWNERS.TXT
index ec4561d99169..3339c039ff85 100644
--- a/CODE_OWNERS.TXT
+++ b/CODE_OWNERS.TXT
@@ -195,6 +195,7 @@ D: MemorySanitizer (LLVM part)
N: Craig Topper
E: craig.topper@gmail.com
+E: craig.topper@intel.com
D: X86 Backend
N: Ulrich Weigand
diff --git a/CREDITS.TXT b/CREDITS.TXT
index 20bd553ae2bc..1773f9dd52d0 100644
--- a/CREDITS.TXT
+++ b/CREDITS.TXT
@@ -220,7 +220,7 @@ W: http://randomhacks.net/
D: llvm-config script
N: Anton Korobeynikov
-E: asl@math.spbu.ru
+E: anton at korobeynikov dot info
D: Mingw32 fixes, cross-compiling support, stdcall/fastcall calling conv.
D: x86/linux PIC codegen, aliases, regparm/visibility attributes
D: Switch lowering refactoring
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index e011bb402757..2b54bdbf2900 100755
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -1133,6 +1133,19 @@ function(configure_lit_site_cfg input output)
set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!")
+ # Override config_target_triple (and the env)
+ if(LLVM_TARGET_TRIPLE_ENV)
+ # This is expanded into the heading.
+ string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}\n\n"
+ "import os\n"
+ "target_env = \"${LLVM_TARGET_TRIPLE_ENV}\"\n"
+ "config.target_triple = config.environment[target_env] = os.environ.get(target_env, \"${TARGET_TRIPLE}\")\n"
+ )
+
+ # This is expanded to; config.target_triple = ""+config.target_triple+""
+ set(TARGET_TRIPLE "\"+config.target_triple+\"")
+ endif()
+
configure_file(${input} ${output} @ONLY)
endfunction()
diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake
index c3325db11788..98f58d7b197d 100644
--- a/cmake/modules/HandleLLVMOptions.cmake
+++ b/cmake/modules/HandleLLVMOptions.cmake
@@ -642,6 +642,9 @@ if(LLVM_USE_SANITIZER)
append_common_sanitizer_flags()
append("-fsanitize=address,undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all"
CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
+ append_common_sanitizer_flags()
+ append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
else()
message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
endif()
diff --git a/cmake/modules/TableGen.cmake b/cmake/modules/TableGen.cmake
index 21421e4fdbd2..8c3e2d7d7004 100644
--- a/cmake/modules/TableGen.cmake
+++ b/cmake/modules/TableGen.cmake
@@ -14,8 +14,31 @@ function(tablegen project ofn)
message(FATAL_ERROR "${project}_TABLEGEN_EXE not set")
endif()
- file(GLOB local_tds "*.td")
- file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
+ # Use depfile instead of globbing arbitrary *.td(s)
+ # DEPFILE is available for Ninja Generator with CMake>=3.7.
+ if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_VERSION VERSION_LESS 3.7)
+ # Make output path relative to build.ninja, assuming located on
+ # ${CMAKE_BINARY_DIR}.
+ # CMake emits build targets as relative paths but Ninja doesn't identify
+ # absolute path (in *.d) as relative path (in build.ninja)
+ # Note that tblgen is executed on ${CMAKE_BINARY_DIR} as working directory.
+ file(RELATIVE_PATH ofn_rel
+ ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${ofn})
+ set(additional_cmdline
+ -o ${ofn_rel}.tmp
+ -d ${ofn_rel}.d
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.d
+ )
+ set(local_tds)
+ set(global_tds)
+ else()
+ file(GLOB local_tds "*.td")
+ file(GLOB_RECURSE global_tds "${LLVM_MAIN_INCLUDE_DIR}/llvm/*.td")
+ set(additional_cmdline
+ -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ )
+ endif()
if (IS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
set(LLVM_TARGET_DEFINITIONS_ABSOLUTE ${LLVM_TARGET_DEFINITIONS})
@@ -44,7 +67,7 @@ function(tablegen project ofn)
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
${LLVM_TABLEGEN_FLAGS}
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
- -o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
+ ${additional_cmdline}
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
# directory and local_tds may not contain it, so we must
# explicitly list it here:
@@ -104,7 +127,8 @@ macro(add_tablegen target project)
set(${target}_OLD_LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS})
set(LLVM_LINK_COMPONENTS ${LLVM_LINK_COMPONENTS} TableGen)
- if(NOT XCODE)
+ # CMake-3.9 doesn't let compilation units depend on their dependent libraries.
+ if(NOT (CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_VERSION VERSION_LESS 3.9) AND NOT XCODE)
# FIXME: It leaks to user, callee of add_tablegen.
set(LLVM_ENABLE_OBJLIB ON)
endif()
diff --git a/docs/AMDGPUUsage.rst b/docs/AMDGPUUsage.rst
index caa697ca28cd..57822ae9ab0a 100644
--- a/docs/AMDGPUUsage.rst
+++ b/docs/AMDGPUUsage.rst
@@ -587,7 +587,7 @@ Code Object Metadata
The code object metadata is specified by the ``NT_AMD_AMDHSA_METADATA`` note
record (see :ref:`amdgpu-note-records`).
-The metadata is specified as a YAML formated string (see [YAML]_ and
+The metadata is specified as a YAML formatted string (see [YAML]_ and
:doc:`YamlIO`).
The metadata is represented as a single YAML document comprised of the mapping
@@ -1031,11 +1031,11 @@ Global variable
appropriate section according to if it has initialized data or is readonly.
If the symbol is external then its section is ``STN_UNDEF`` and the loader
- will resolve relocations using the defintion provided by another code object
+ will resolve relocations using the definition provided by another code object
or explicitly defined by the runtime.
All global symbols, whether defined in the compilation unit or external, are
- accessed by the machine code indirectly throught a GOT table entry. This
+ accessed by the machine code indirectly through a GOT table entry. This
allows them to be preemptable. The GOT table is only supported when the target
triple OS is ``amdhsa`` (see :ref:`amdgpu-target-triples`).
@@ -1160,7 +1160,7 @@ Register Mapping
Define DWARF register enumeration.
If want to present a wavefront state then should expose vector registers as
- 64 wide (rather than per work-item view that LLVM uses). Either as seperate
+ 64 wide (rather than per work-item view that LLVM uses). Either as separate
registers, or a 64x4 byte single register. In either case use a new LANE op
(akin to XDREF) to select the current lane usage in a location
expression. This would also allow scalar register spilling to vector register
@@ -1653,7 +1653,7 @@ CP microcode requires the Kernel descritor to be allocated on 64 byte alignment.
``COMPUTE_PGM_RSRC2.USER_SGPR``.
6 1 bit enable_trap_handler Set to 1 if code contains a
TRAP instruction which
- requires a trap hander to
+ requires a trap handler to
be enabled.
CP sets
@@ -2146,7 +2146,7 @@ This section describes the mapping of LLVM memory model onto AMDGPU machine code
.. TODO
Update when implementation complete.
- Support more relaxed OpenCL memory model to be controled by environment
+ Support more relaxed OpenCL memory model to be controlled by environment
component of target triple.
The AMDGPU backend supports the memory synchronization scopes specified in
@@ -2201,7 +2201,7 @@ For GFX6-GFX9:
can be reordered relative to each other, which can result in reordering the
visibility of vector memory operations with respect to LDS operations of other
wavefronts in the same work-group. A ``s_waitcnt lgkmcnt(0)`` is required to
- ensure synchonization between LDS operations and vector memory operations
+ ensure synchronization between LDS operations and vector memory operations
between waves of a work-group, but not between operations performed by the
same wavefront.
* The vector memory operations are performed as wavefront wide operations and
@@ -2226,7 +2226,7 @@ For GFX6-GFX9:
scalar memory operations performed by waves executing in different work-groups
(which may be executing on different CUs) of an agent can be reordered
relative to each other. A ``s_waitcnt vmcnt(0)`` is required to ensure
- synchonization between vector memory operations of different CUs. It ensures a
+ synchronization between vector memory operations of different CUs. It ensures a
previous vector memory operation has completed before executing a subsequent
vector memory or LDS operation and so can be used to meet the requirements of
acquire and release.
@@ -2268,7 +2268,7 @@ and vector L1 caches are invalidated between kernel dispatches by CP since
constant address space data may change between kernel dispatch executions. See
:ref:`amdgpu-amdhsa-memory-spaces`.
-The one exeception is if scalar writes are used to spill SGPR registers. In this
+The one execption is if scalar writes are used to spill SGPR registers. In this
case the AMDGPU backend ensures the memory location used to spill is never
accessed by vector memory operations at the same time. If scalar writes are used
then a ``s_dcache_wb`` is inserted before the ``s_endpgm`` and before a function
@@ -3310,7 +3310,7 @@ table
be moved before the acquire.
- If a fence then same as load atomic, plus no preceding
associated fence-paired-atomic can be moved after the fence.
- release - If a store atomic/atomicrmw then no preceeding load/load
+ release - If a store atomic/atomicrmw then no preceding load/load
atomic/store/ store atomic/atomicrmw/fence instruction can
be moved after the release.
- If a fence then same as store atomic, plus no following
diff --git a/docs/GetElementPtr.rst b/docs/GetElementPtr.rst
index d13479dabca8..b593871695fa 100644
--- a/docs/GetElementPtr.rst
+++ b/docs/GetElementPtr.rst
@@ -27,7 +27,7 @@ questions.
What is the first index of the GEP instruction?
-----------------------------------------------
-Quick answer: The index stepping through the first operand.
+Quick answer: The index stepping through the second operand.
The confusion with the first index usually arises from thinking about the
GetElementPtr instruction as if it was a C index operator. They aren't the
@@ -59,7 +59,7 @@ Sometimes this question gets rephrased as:
won't be dereferenced?*
The answer is simply because memory does not have to be accessed to perform the
-computation. The first operand to the GEP instruction must be a value of a
+computation. The second operand to the GEP instruction must be a value of a
pointer type. The value of the pointer is provided directly to the GEP
instruction as an operand without any need for accessing memory. It must,
therefore be indexed and requires an index operand. Consider this example:
@@ -80,8 +80,8 @@ therefore be indexed and requires an index operand. Consider this example:
In this "C" example, the front end compiler (Clang) will generate three GEP
instructions for the three indices through "P" in the assignment statement. The
-function argument ``P`` will be the first operand of each of these GEP
-instructions. The second operand indexes through that pointer. The third
+function argument ``P`` will be the second operand of each of these GEP
+instructions. The third operand indexes through that pointer. The fourth
operand will be the field offset into the ``struct munger_struct`` type, for
either the ``f1`` or ``f2`` field. So, in LLVM assembly the ``munge`` function
looks like:
@@ -100,8 +100,8 @@ looks like:
ret void
}
-In each case the first operand is the pointer through which the GEP instruction
-starts. The same is true whether the first operand is an argument, allocated
+In each case the second operand is the pointer through which the GEP instruction
+starts. The same is true whether the second operand is an argument, allocated
memory, or a global variable.
To make this clear, let's consider a more obtuse example:
@@ -159,11 +159,11 @@ confusion:
i32 }*``. That is, ``%MyStruct`` is a pointer to a structure containing a
pointer to a ``float`` and an ``i32``.
-#. Point #1 is evidenced by noticing the type of the first operand of the GEP
+#. Point #1 is evidenced by noticing the type of the second operand of the GEP
instruction (``%MyStruct``) which is ``{ float*, i32 }*``.
#. The first index, ``i64 0`` is required to step over the global variable
- ``%MyStruct``. Since the first argument to the GEP instruction must always
+ ``%MyStruct``. Since the second argument to the GEP instruction must always
be a value of pointer type, the first index steps through that pointer. A
value of 0 means 0 elements offset from that pointer.
@@ -267,7 +267,7 @@ in the IR. In the future, it will probably be outright disallowed.
What effect do address spaces have on GEPs?
-------------------------------------------
-None, except that the address space qualifier on the first operand pointer type
+None, except that the address space qualifier on the second operand pointer type
always matches the address space qualifier on the result type.
How is GEP different from ``ptrtoint``, arithmetic, and ``inttoptr``?
@@ -526,7 +526,7 @@ instruction:
#. The GEP instruction never accesses memory, it only provides pointer
computations.
-#. The first operand to the GEP instruction is always a pointer and it must be
+#. The second operand to the GEP instruction is always a pointer and it must be
indexed.
#. There are no superfluous indices for the GEP instruction.
diff --git a/docs/GoldPlugin.rst b/docs/GoldPlugin.rst
index 88b944a2a0fd..78d38ccb32bd 100644
--- a/docs/GoldPlugin.rst
+++ b/docs/GoldPlugin.rst
@@ -7,7 +7,7 @@ Introduction
Building with link time optimization requires cooperation from
the system linker. LTO support on Linux systems requires that you use the
-`gold linker`_ which supports LTO via plugins. This is the same mechanism
+`gold linker`_ or ld.bfd from binutils >= 2.21.51.0.2, as they support LTO via plugins. This is the same mechanism
used by the `GCC LTO`_ project.
The LLVM gold plugin implements the gold plugin interface on top of
@@ -23,24 +23,22 @@ The LLVM gold plugin implements the gold plugin interface on top of
How to build it
===============
-You need to have gold with plugin support and build the LLVMgold plugin.
-Check whether you have gold running ``/usr/bin/ld -v``. It will report "GNU
-gold" or else "GNU ld" if not. If you have gold, check for plugin support
-by running ``/usr/bin/ld -plugin``. If it complains "missing argument" then
-you have plugin support. If not, such as an "unknown option" error then you
-will either need to build gold or install a version with plugin support.
+Check for plugin support by running ``/usr/bin/ld -plugin``. If it complains
+"missing argument" then you have plugin support. If not, such as an "unknown option"
+error then you will either need to build gold or install a recent version
+of ld.bfd with plugin support and then build gold plugin.
-* Download, configure and build gold with plugin support:
+* Download, configure and build ld.bfd with plugin support:
.. code-block:: bash
$ git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
$ mkdir build
$ cd build
- $ ../binutils/configure --enable-gold --enable-plugins --disable-werror
- $ make all-gold
+ $ ../binutils/configure --disable-werror # ld.bfd includes plugin support by default
+ $ make all-ld
- That should leave you with ``build/gold/ld-new`` which supports
+ That should leave you with ``build/ld/ld-new`` which supports
the ``-plugin`` option. Running ``make`` will additionally build
``build/binutils/ar`` and ``nm-new`` binaries supporting plugins.
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index 68aa500150ae..2a0812ab930f 100644
--- a/docs/LangRef.rst
+++ b/docs/LangRef.rst
@@ -1468,6 +1468,19 @@ example:
This attribute by itself does not imply restrictions on
inter-procedural optimizations. All of the semantic effects the
patching may have to be separately conveyed via the linkage type.
+``"probe-stack"``
+ This attribute indicates that the function will trigger a guard region
+ in the end of the stack. It ensures that accesses to the stack must be
+ no further apart than the size of the guard region to a previous
+ access of the stack. It takes one required string value, the name of
+ the stack probing function that will be called.
+
+ If a function that has a ``"probe-stack"`` attribute is inlined into
+ a function with another ``"probe-stack"`` attribute, the resulting
+ function has the ``"probe-stack"`` attribute of the caller. If a
+ function that has a ``"probe-stack"`` attribute is inlined into a
+ function that has no ``"probe-stack"`` attribute at all, the resulting
+ function has the ``"probe-stack"`` attribute of the callee.
``readnone``
On a function, this attribute indicates that the function computes its
result (or decides to unwind an exception) based strictly on its arguments,
@@ -1498,6 +1511,21 @@ example:
On an argument, this attribute indicates that the function does not write
through this pointer argument, even though it may write to the memory that
the pointer points to.
+``"stack-probe-size"``
+ This attribute controls the behavior of stack probes: either
+ the ``"probe-stack"`` attribute, or ABI-required stack probes, if any.
+ It defines the size of the guard region. It ensures that if the function
+ may use more stack space than the size of the guard region, stack probing
+ sequence will be emitted. It takes one required integer value, which
+ is 4096 by default.
+
+ If a function that has a ``"stack-probe-size"`` attribute is inlined into
+ a function with another ``"stack-probe-size"`` attribute, the resulting
+ function has the ``"stack-probe-size"`` attribute that has the lower
+ numeric value. If a function that has a ``"stack-probe-size"`` attribute is
+ inlined into a function that has no ``"stack-probe-size"`` attribute
+ at all, the resulting function has the ``"stack-probe-size"`` attribute
+ of the callee.
``writeonly``
On a function, this attribute indicates that the function may write to but
does not read from memory.
@@ -1989,7 +2017,7 @@ A pointer value is *based* on another pointer value according to the
following rules:
- A pointer value formed from a ``getelementptr`` operation is *based*
- on the first value operand of the ``getelementptr``.
+ on the second value operand of the ``getelementptr``.
- The result value of a ``bitcast`` is *based* on the operand of the
``bitcast``.
- A pointer value formed by an ``inttoptr`` is *based* on all pointer
@@ -3166,7 +3194,7 @@ The following is the syntax for constant expressions:
``getelementptr (TY, CSTPTR, IDX0, IDX1, ...)``, ``getelementptr inbounds (TY, CSTPTR, IDX0, IDX1, ...)``
Perform the :ref:`getelementptr operation <i_getelementptr>` on
constants. As with the :ref:`getelementptr <i_getelementptr>`
- instruction, the index list may have zero or more indexes, which are
+ instruction, the index list may have one or more indexes, which are
required to make sense for the type of "pointer to TY".
``select (COND, VAL1, VAL2)``
Perform the :ref:`select operation <i_select>` on constants.
@@ -7805,7 +7833,7 @@ base address to start from. The remaining arguments are indices
that indicate which of the elements of the aggregate object are indexed.
The interpretation of each index is dependent on the type being indexed
into. The first index always indexes the pointer value given as the
-first argument, the second index indexes a value of the type pointed to
+second argument, the second index indexes a value of the type pointed to
(not necessarily the value directly pointed to, since the first index
can be non-zero), etc. The first type indexed into must be a pointer
value, subsequent types can be arrays, vectors, and structs. Note that
diff --git a/docs/Proposals/VectorizationPlan.rst b/docs/Proposals/VectorizationPlan.rst
index 82ce4b2de17a..aed8e3d2b793 100644
--- a/docs/Proposals/VectorizationPlan.rst
+++ b/docs/Proposals/VectorizationPlan.rst
@@ -27,7 +27,7 @@ Vectorization Workflow
VPlan-based vectorization involves three major steps, taking a "scenario-based
approach" to vectorization planning:
-1. Legal Step: check if a loop can be legally vectorized; encode contraints and
+1. Legal Step: check if a loop can be legally vectorized; encode constraints and
artifacts if so.
2. Plan Step:
diff --git a/docs/XRay.rst b/docs/XRay.rst
index d650319e9922..e43f78e5ffe5 100644
--- a/docs/XRay.rst
+++ b/docs/XRay.rst
@@ -150,7 +150,7 @@ variable, where we list down the options and their defaults below.
| xray_logfile_base | ``const char*`` | ``xray-log.`` | Filename base for the |
| | | | XRay logfile. |
+-------------------+-----------------+---------------+------------------------+
-| xray_fdr_log | ``bool`` | ``false`` | Wheter to install the |
+| xray_fdr_log | ``bool`` | ``false`` | Whether to install the |
| | | | Flight Data Recorder |
| | | | (FDR) mode. |
+-------------------+-----------------+---------------+------------------------+
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
index 847662cc11be..f99722f60e91 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
@@ -40,11 +40,11 @@ class KaleidoscopeJIT {
private:
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
- RTDyldObjectLinkingLayer<> ObjectLayer;
- IRCompileLayer<decltype(ObjectLayer)> CompileLayer;
+ RTDyldObjectLinkingLayer ObjectLayer;
+ IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
public:
- using ModuleHandle = decltype(CompileLayer)::ModuleSetHandleT;
+ using ModuleHandle = decltype(CompileLayer)::ModuleHandleT;
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
@@ -72,15 +72,11 @@ public:
return JITSymbol(nullptr);
});
- // Build a singleton module set to hold our module.
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
-
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return CompileLayer.addModuleSet(std::move(Ms),
- make_unique<SectionMemoryManager>(),
- std::move(Resolver));
+ return CompileLayer.addModule(std::move(M),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
JITSymbol findSymbol(const std::string Name) {
@@ -91,7 +87,7 @@ public:
}
void removeModule(ModuleHandle H) {
- CompileLayer.removeModuleSet(H);
+ CompileLayer.removeModule(H);
}
};
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
index a5ac2f017b74..2cd4ed79aafa 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
@@ -44,22 +44,22 @@ class KaleidoscopeJIT {
private:
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
- RTDyldObjectLinkingLayer<> ObjectLayer;
- IRCompileLayer<decltype(ObjectLayer)> CompileLayer;
+ RTDyldObjectLinkingLayer ObjectLayer;
+ IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
+ std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT;
+ using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
OptimizeLayer(CompileLayer,
- [this](std::unique_ptr<Module> M) {
+ [this](std::shared_ptr<Module> M) {
return optimizeModule(std::move(M));
}) {
llvm::sys::DynamicLibrary::LoadLibraryPermanently(nullptr);
@@ -85,15 +85,11 @@ public:
return JITSymbol(nullptr);
});
- // Build a singleton module set to hold our module.
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
-
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModuleSet(std::move(Ms),
- make_unique<SectionMemoryManager>(),
- std::move(Resolver));
+ return OptimizeLayer.addModule(std::move(M),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
JITSymbol findSymbol(const std::string Name) {
@@ -104,11 +100,11 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModuleSet(H);
+ OptimizeLayer.removeModule(H);
}
private:
- std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
+ std::shared_ptr<Module> optimizeModule(std::shared_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
index 7acb9c748880..f6fb3071d526 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
@@ -47,11 +47,11 @@ class KaleidoscopeJIT {
private:
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
- RTDyldObjectLinkingLayer<> ObjectLayer;
- IRCompileLayer<decltype(ObjectLayer)> CompileLayer;
+ RTDyldObjectLinkingLayer ObjectLayer;
+ IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
+ std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
@@ -59,13 +59,13 @@ private:
CompileOnDemandLayer<decltype(OptimizeLayer)> CODLayer;
public:
- using ModuleHandle = decltype(CODLayer)::ModuleSetHandleT;
+ using ModuleHandle = decltype(CODLayer)::ModuleHandleT;
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
OptimizeLayer(CompileLayer,
- [this](std::unique_ptr<Module> M) {
+ [this](std::shared_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
CompileCallbackManager(
@@ -98,15 +98,11 @@ public:
return JITSymbol(nullptr);
});
- // Build a singleton module set to hold our module.
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
-
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return CODLayer.addModuleSet(std::move(Ms),
- make_unique<SectionMemoryManager>(),
- std::move(Resolver));
+ return CODLayer.addModule(std::move(M),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
JITSymbol findSymbol(const std::string Name) {
@@ -117,11 +113,11 @@ public:
}
void removeModule(ModuleHandle H) {
- CODLayer.removeModuleSet(H);
+ CODLayer.removeModule(H);
}
private:
- std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
+ std::shared_ptr<Module> optimizeModule(std::shared_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
index 03e42230ae71..d45874e9a693 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
@@ -73,11 +73,11 @@ class KaleidoscopeJIT {
private:
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
- RTDyldObjectLinkingLayer<> ObjectLayer;
- IRCompileLayer<decltype(ObjectLayer)> CompileLayer;
+ RTDyldObjectLinkingLayer ObjectLayer;
+ IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
+ std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
@@ -85,14 +85,14 @@ private:
std::unique_ptr<IndirectStubsManager> IndirectStubsMgr;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT;
+ using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()),
DL(TM->createDataLayout()),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
OptimizeLayer(CompileLayer,
- [this](std::unique_ptr<Module> M) {
+ [this](std::shared_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
CompileCallbackMgr(
@@ -125,15 +125,11 @@ public:
return JITSymbol(nullptr);
});
- // Build a singleton module set to hold our module.
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
-
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModuleSet(std::move(Ms),
- make_unique<SectionMemoryManager>(),
- std::move(Resolver));
+ return OptimizeLayer.addModule(std::move(M),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -199,7 +195,7 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModuleSet(H);
+ OptimizeLayer.removeModule(H);
}
private:
@@ -210,7 +206,7 @@ private:
return MangledNameStream.str();
}
- std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
+ std::shared_ptr<Module> optimizeModule(std::shared_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
index 0ee9d094ab82..e889c6d34322 100644
--- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
@@ -78,11 +78,11 @@ class KaleidoscopeJIT {
private:
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
- RTDyldObjectLinkingLayer<> ObjectLayer;
- IRCompileLayer<decltype(ObjectLayer)> CompileLayer;
+ RTDyldObjectLinkingLayer ObjectLayer;
+ IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
using OptimizeFunction =
- std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;
+ std::function<std::shared_ptr<Module>(std::shared_ptr<Module>)>;
IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
@@ -91,7 +91,7 @@ private:
MyRemote &Remote;
public:
- using ModuleHandle = decltype(OptimizeLayer)::ModuleSetHandleT;
+ using ModuleHandle = decltype(OptimizeLayer)::ModuleHandleT;
KaleidoscopeJIT(MyRemote &Remote)
: TM(EngineBuilder().selectTarget(Triple(Remote.getTargetTriple()), "",
@@ -99,7 +99,7 @@ public:
DL(TM->createDataLayout()),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
OptimizeLayer(CompileLayer,
- [this](std::unique_ptr<Module> M) {
+ [this](std::shared_ptr<Module> M) {
return optimizeModule(std::move(M));
}),
Remote(Remote) {
@@ -153,15 +153,11 @@ public:
exit(1);
}
- // Build a singleton module set to hold our module.
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
-
// Add the set to the JIT with the resolver we created above and a newly
// created SectionMemoryManager.
- return OptimizeLayer.addModuleSet(std::move(Ms),
- std::move(MemMgr),
- std::move(Resolver));
+ return OptimizeLayer.addModule(std::move(M),
+ std::move(MemMgr),
+ std::move(Resolver));
}
Error addFunctionAST(std::unique_ptr<FunctionAST> FnAST) {
@@ -231,7 +227,7 @@ public:
}
void removeModule(ModuleHandle H) {
- OptimizeLayer.removeModuleSet(H);
+ OptimizeLayer.removeModule(H);
}
private:
@@ -242,7 +238,7 @@ private:
return MangledNameStream.str();
}
- std::unique_ptr<Module> optimizeModule(std::unique_ptr<Module> M) {
+ std::shared_ptr<Module> optimizeModule(std::shared_ptr<Module> M) {
// Create a function pass manager.
auto FPM = llvm::make_unique<legacy::FunctionPassManager>(M.get());
diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/examples/Kaleidoscope/include/KaleidoscopeJIT.h
index 9a682f7ab744..fe73d717976d 100644
--- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h
+++ b/examples/Kaleidoscope/include/KaleidoscopeJIT.h
@@ -39,9 +39,9 @@ namespace orc {
class KaleidoscopeJIT {
public:
- using ObjLayerT = RTDyldObjectLinkingLayer<>;
- using CompileLayerT = IRCompileLayer<ObjLayerT>;
- using ModuleHandleT = CompileLayerT::ModuleSetHandleT;
+ using ObjLayerT = RTDyldObjectLinkingLayer;
+ using CompileLayerT = IRCompileLayer<ObjLayerT, SimpleCompiler>;
+ using ModuleHandleT = CompileLayerT::ModuleHandleT;
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
@@ -62,9 +62,9 @@ public:
return JITSymbol(nullptr);
},
[](const std::string &S) { return nullptr; });
- auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)),
- make_unique<SectionMemoryManager>(),
- std::move(Resolver));
+ auto H = CompileLayer.addModule(std::move(M),
+ make_unique<SectionMemoryManager>(),
+ std::move(Resolver));
ModuleHandles.push_back(H);
return H;
@@ -72,7 +72,7 @@ public:
void removeModule(ModuleHandleT H) {
ModuleHandles.erase(find(ModuleHandles, H));
- CompileLayer.removeModuleSet(H);
+ CompileLayer.removeModule(H);
}
JITSymbol findSymbol(const std::string Name) {
@@ -89,12 +89,6 @@ private:
return MangledName;
}
- template <typename T> static std::vector<T> singletonSet(T t) {
- std::vector<T> Vec;
- Vec.push_back(std::move(t));
- return Vec;
- }
-
JITSymbol findMangledSymbol(const std::string &Name) {
#ifdef LLVM_ON_WIN32
// The symbol lookup of ObjectLinkingLayer uses the SymbolRef::SF_Exported
diff --git a/include/llvm-c/OrcBindings.h b/include/llvm-c/OrcBindings.h
index de2969ab1c9b..d86ea8808889 100644
--- a/include/llvm-c/OrcBindings.h
+++ b/include/llvm-c/OrcBindings.h
@@ -29,6 +29,8 @@
extern "C" {
#endif
+typedef struct LLVMOpaqueSharedModule *LLVMSharedModuleRef;
+typedef struct LLVMOpaqueSharedObjectBuffer *LLVMSharedObjectBufferRef;
typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef;
typedef uint32_t LLVMOrcModuleHandle;
typedef uint64_t LLVMOrcTargetAddress;
@@ -39,6 +41,45 @@ typedef uint64_t (*LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack,
typedef enum { LLVMOrcErrSuccess = 0, LLVMOrcErrGeneric } LLVMOrcErrorCode;
/**
+ * Turn an LLVMModuleRef into an LLVMSharedModuleRef.
+ *
+ * The JIT uses shared ownership for LLVM modules, since it is generally
+ * difficult to know when the JIT will be finished with a module (and the JIT
+ * has no way of knowing when a user may be finished with one).
+ *
+ * Calling this method with an LLVMModuleRef creates a shared-pointer to the
+ * module, and returns a reference to this shared pointer.
+ *
+ * The shared module should be disposed when finished with by calling
+ * LLVMOrcDisposeSharedModule (not LLVMDisposeModule). The Module will be
+ * deleted when the last shared pointer owner relinquishes it.
+ */
+
+LLVMSharedModuleRef LLVMOrcMakeSharedModule(LLVMModuleRef Mod);
+
+/**
+ * Dispose of a shared module.
+ *
+ * The module should not be accessed after this call. The module will be
+ * deleted once all clients (including the JIT itself) have released their
+ * shared pointers.
+ */
+
+void LLVMOrcDisposeSharedModuleRef(LLVMSharedModuleRef SharedMod);
+
+/**
+ * Get an LLVMSharedObjectBufferRef from an LLVMMemoryBufferRef.
+ */
+LLVMSharedObjectBufferRef
+LLVMOrcMakeSharedObjectBuffer(LLVMMemoryBufferRef ObjBuffer);
+
+/**
+ * Dispose of a shared object buffer.
+ */
+void
+LLVMOrcDisposeSharedObjectBufferRef(LLVMSharedObjectBufferRef SharedObjBuffer);
+
+/**
* Create an ORC JIT stack.
*
* The client owns the resulting stack, and must call OrcDisposeInstance(...)
@@ -95,7 +136,8 @@ LLVMOrcErrorCode LLVMOrcSetIndirectStubPointer(LLVMOrcJITStackRef JITStack,
* Add module to be eagerly compiled.
*/
LLVMOrcModuleHandle
-LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
+LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack,
+ LLVMSharedModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
@@ -103,7 +145,8 @@ LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
* Add module to be lazily compiled one function at a time.
*/
LLVMOrcModuleHandle
-LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
+LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack,
+ LLVMSharedModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
@@ -111,7 +154,7 @@ LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack, LLVMModuleRef Mod,
* Add an object file.
*/
LLVMOrcModuleHandle LLVMOrcAddObjectFile(LLVMOrcJITStackRef JITStack,
- LLVMObjectFileRef Obj,
+ LLVMSharedObjectBufferRef Obj,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
diff --git a/include/llvm/ADT/APFloat.h b/include/llvm/ADT/APFloat.h
index bef6efde1f01..9c5e392c4808 100644
--- a/include/llvm/ADT/APFloat.h
+++ b/include/llvm/ADT/APFloat.h
@@ -140,8 +140,8 @@ enum lostFraction { // Example of truncated bits:
// implementation classes. This struct should not define any non-static data
// members.
struct APFloatBase {
- // TODO remove this and use APInt typedef directly.
typedef APInt::WordType integerPart;
+ static const unsigned integerPartWidth = APInt::APINT_BITS_PER_WORD;
/// A signed type to represent a floating point numbers unbiased exponent.
typedef signed short ExponentType;
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h
index ef9c66d2d700..e5f0c35534ac 100644
--- a/include/llvm/ADT/APInt.h
+++ b/include/llvm/ADT/APInt.h
@@ -213,6 +213,12 @@ private:
/// out-of-line slow case for countLeadingZeros
unsigned countLeadingZerosSlowCase() const LLVM_READONLY;
+ /// out-of-line slow case for countLeadingOnes.
+ unsigned countLeadingOnesSlowCase() const LLVM_READONLY;
+
+ /// out-of-line slow case for countTrailingZeros.
+ unsigned countTrailingZerosSlowCase() const LLVM_READONLY;
+
/// out-of-line slow case for countTrailingOnes
unsigned countTrailingOnesSlowCase() const LLVM_READONLY;
@@ -383,7 +389,7 @@ public:
bool isAllOnesValue() const {
if (isSingleWord())
return U.VAL == WORD_MAX >> (APINT_BITS_PER_WORD - BitWidth);
- return countPopulationSlowCase() == BitWidth;
+ return countTrailingOnesSlowCase() == BitWidth;
}
/// \brief Determine if all bits are clear
@@ -408,7 +414,9 @@ public:
/// This checks to see if the value of this APInt is the maximum signed
/// value for the APInt's bit width.
bool isMaxSignedValue() const {
- return !isNegative() && countPopulation() == BitWidth - 1;
+ if (isSingleWord())
+ return U.VAL == ((WordType(1) << (BitWidth - 1)) - 1);
+ return !isNegative() && countTrailingOnesSlowCase() == BitWidth - 1;
}
/// \brief Determine if this is the smallest unsigned value.
@@ -422,7 +430,9 @@ public:
/// This checks to see if the value of this APInt is the minimum signed
/// value for the APInt's bit width.
bool isMinSignedValue() const {
- return isNegative() && isPowerOf2();
+ if (isSingleWord())
+ return U.VAL == (WordType(1) << (BitWidth - 1));
+ return isNegative() && countTrailingZerosSlowCase() == BitWidth - 1;
}
/// \brief Check if this APInt has an N-bits unsigned integer value.
@@ -1574,7 +1584,11 @@ public:
///
/// \returns 0 if the high order bit is not set, otherwise returns the number
/// of 1 bits from the most significant to the least
- unsigned countLeadingOnes() const LLVM_READONLY;
+ unsigned countLeadingOnes() const {
+ if (isSingleWord())
+ return llvm::countLeadingOnes(U.VAL << (APINT_BITS_PER_WORD - BitWidth));
+ return countLeadingOnesSlowCase();
+ }
/// Computes the number of leading bits of this APInt that are equal to its
/// sign bit.
@@ -1590,7 +1604,11 @@ public:
///
/// \returns BitWidth if the value is zero, otherwise returns the number of
/// zeros from the least significant bit to the first one bit.
- unsigned countTrailingZeros() const LLVM_READONLY;
+ unsigned countTrailingZeros() const {
+ if (isSingleWord())
+ return std::min(unsigned(llvm::countTrailingZeros(U.VAL)), BitWidth);
+ return countTrailingZerosSlowCase();
+ }
/// \brief Count the number of trailing one bits.
///
diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h
index ffcf998a3d32..cc32bf43f29c 100644
--- a/include/llvm/ADT/StringExtras.h
+++ b/include/llvm/ADT/StringExtras.h
@@ -15,10 +15,12 @@
#define LLVM_ADT_STRINGEXTRAS_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
+#include <cstdlib>
#include <cstring>
#include <iterator>
#include <string>
@@ -129,6 +131,32 @@ template <typename N> bool to_integer(StringRef S, N &Num, unsigned Base = 0) {
return !S.getAsInteger(Base, Num);
}
+namespace detail {
+template <typename N>
+inline bool to_float(const Twine &T, N &Num, N (*StrTo)(const char *, char **)) {
+ SmallString<32> Storage;
+ StringRef S = T.toNullTerminatedStringRef(Storage);
+ char *End;
+ N Temp = StrTo(S.data(), &End);
+ if (*End != '\0')
+ return false;
+ Num = Temp;
+ return true;
+}
+}
+
+inline bool to_float(const Twine &T, float &Num) {
+ return detail::to_float(T, Num, strtof);
+}
+
+inline bool to_float(const Twine &T, double &Num) {
+ return detail::to_float(T, Num, strtod);
+}
+
+inline bool to_float(const Twine &T, long double &Num) {
+ return detail::to_float(T, Num, strtold);
+}
+
static inline std::string utostr(uint64_t X, bool isNeg = false) {
char Buffer[21];
char *BufPtr = std::end(Buffer);
diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h
index 26a991812a3a..cd560658ca4e 100644
--- a/include/llvm/ADT/Triple.h
+++ b/include/llvm/ADT/Triple.h
@@ -147,6 +147,7 @@ public:
enum OSType {
UnknownOS,
+ Ananas,
CloudABI,
Darwin,
DragonFly,
diff --git a/include/llvm/Analysis/LazyValueInfo.h b/include/llvm/Analysis/LazyValueInfo.h
index 7b178fc7bcc2..787c88cc6ec1 100644
--- a/include/llvm/Analysis/LazyValueInfo.h
+++ b/include/llvm/Analysis/LazyValueInfo.h
@@ -93,6 +93,13 @@ public:
Constant *getConstantOnEdge(Value *V, BasicBlock *FromBB, BasicBlock *ToBB,
Instruction *CxtI = nullptr);
+ /// Return the ConstantRage constraint that is known to hold for the
+ /// specified value on the specified edge. This may be only be called
+ /// on integer-typed Values.
+ ConstantRange getConstantRangeOnEdge(Value *V, BasicBlock *FromBB,
+ BasicBlock *ToBB,
+ Instruction *CxtI = nullptr);
+
/// Inform the analysis cache that we have threaded an edge from
/// PredBB to OldSucc to be from PredBB to NewSucc instead.
void threadEdge(BasicBlock *PredBB, BasicBlock *OldSucc, BasicBlock *NewSucc);
diff --git a/include/llvm/Analysis/Loads.h b/include/llvm/Analysis/Loads.h
index a59c1f88e229..f110c28bfc6d 100644
--- a/include/llvm/Analysis/Loads.h
+++ b/include/llvm/Analysis/Loads.h
@@ -39,6 +39,15 @@ bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
const Instruction *CtxI = nullptr,
const DominatorTree *DT = nullptr);
+/// Returns true if V is always dereferenceable for Size byte with alignment
+/// greater or equal than requested. If the context instruction is specified
+/// performs context-sensitive analysis and returns true if the pointer is
+/// dereferenceable at the specified instruction.
+bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align,
+ const APInt &Size, const DataLayout &DL,
+ const Instruction *CtxI = nullptr,
+ const DominatorTree *DT = nullptr);
+
/// Return true if we know that executing a load from this value cannot trap.
///
/// If DT and ScanFrom are specified this method performs context-sensitive
diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h
index 6ff4335f1ad5..372fc8b21745 100644
--- a/include/llvm/Analysis/LoopInfoImpl.h
+++ b/include/llvm/Analysis/LoopInfoImpl.h
@@ -91,8 +91,9 @@ getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const {
/// getLoopPreheader - If there is a preheader for this loop, return it. A
/// loop has a preheader if there is only one edge to the header of the loop
-/// from outside of the loop. If this is the case, the block branching to the
-/// header of the loop is the preheader node.
+/// from outside of the loop and it is legal to hoist instructions into the
+/// predecessor. If this is the case, the block branching to the header of the
+/// loop is the preheader node.
///
/// This method returns null if there is no preheader for the loop.
///
@@ -102,6 +103,10 @@ BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader() const {
BlockT *Out = getLoopPredecessor();
if (!Out) return nullptr;
+ // Make sure we are allowed to hoist instructions into the predecessor.
+ if (!Out->isLegalToHoistInto())
+ return nullptr;
+
// Make sure there is only one exit out of the preheader.
typedef GraphTraits<BlockT*> BlockTraits;
typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(Out);
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index 2a4b768256d1..002a3174fd19 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -784,7 +784,9 @@ private:
}
/// Determine the range for a particular SCEV.
- ConstantRange getRange(const SCEV *S, RangeSignHint Hint);
+ /// NOTE: This returns a reference to an entry in a cache. It must be
+ /// copied if its needed for longer.
+ const ConstantRange &getRangeRef(const SCEV *S, RangeSignHint Hint);
/// Determines the range for the affine SCEVAddRecExpr {\p Start,+,\p Stop}.
/// Helper for \c getRange.
@@ -1464,15 +1466,35 @@ public:
uint32_t GetMinTrailingZeros(const SCEV *S);
/// Determine the unsigned range for a particular SCEV.
- ///
+ /// NOTE: This returns a copy of the reference returned by getRangeRef.
ConstantRange getUnsignedRange(const SCEV *S) {
- return getRange(S, HINT_RANGE_UNSIGNED);
+ return getRangeRef(S, HINT_RANGE_UNSIGNED);
+ }
+
+ /// Determine the min of the unsigned range for a particular SCEV.
+ APInt getUnsignedRangeMin(const SCEV *S) {
+ return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMin();
+ }
+
+ /// Determine the max of the unsigned range for a particular SCEV.
+ APInt getUnsignedRangeMax(const SCEV *S) {
+ return getRangeRef(S, HINT_RANGE_UNSIGNED).getUnsignedMax();
}
/// Determine the signed range for a particular SCEV.
- ///
+ /// NOTE: This returns a copy of the reference returned by getRangeRef.
ConstantRange getSignedRange(const SCEV *S) {
- return getRange(S, HINT_RANGE_SIGNED);
+ return getRangeRef(S, HINT_RANGE_SIGNED);
+ }
+
+ /// Determine the min of the signed range for a particular SCEV.
+ APInt getSignedRangeMin(const SCEV *S) {
+ return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMin();
+ }
+
+ /// Determine the max of the signed range for a particular SCEV.
+ APInt getSignedRangeMax(const SCEV *S) {
+ return getRangeRef(S, HINT_RANGE_SIGNED).getSignedMax();
}
/// Test if the given expression is known to be negative.
diff --git a/include/llvm/BinaryFormat/COFF.h b/include/llvm/BinaryFormat/COFF.h
index 5171c72b9e67..df173a80e09b 100644
--- a/include/llvm/BinaryFormat/COFF.h
+++ b/include/llvm/BinaryFormat/COFF.h
@@ -46,6 +46,12 @@ static const char ClGlObjMagic[] = {
'\xac', '\x9b', '\xd6', '\xb6', '\x22', '\x26', '\x53', '\xc2',
};
+// The signature bytes that start a .res file.
+static const char WinResMagic[] = {
+ '\x00', '\x00', '\x00', '\x00', '\x20', '\x00', '\x00', '\x00',
+ '\xff', '\xff', '\x00', '\x00', '\xff', '\xff', '\x00', '\x00',
+};
+
// Sizes in bytes of various things in the COFF format.
enum {
Header16Size = 20,
diff --git a/include/llvm/BinaryFormat/Dwarf.h b/include/llvm/BinaryFormat/Dwarf.h
index b7a056b18119..ab927565d05d 100644
--- a/include/llvm/BinaryFormat/Dwarf.h
+++ b/include/llvm/BinaryFormat/Dwarf.h
@@ -484,7 +484,7 @@ private:
};
/// Constants that define the DWARF format as 32 or 64 bit.
-enum DwarfFormat { DWARF32, DWARF64 };
+enum DwarfFormat : uint8_t { DWARF32, DWARF64 };
} // End of namespace dwarf
diff --git a/include/llvm/BinaryFormat/MachO.h b/include/llvm/BinaryFormat/MachO.h
index 8ab6dde800c2..3529c72acd9d 100644
--- a/include/llvm/BinaryFormat/MachO.h
+++ b/include/llvm/BinaryFormat/MachO.h
@@ -78,7 +78,8 @@ enum {
MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u,
MH_HAS_TLV_DESCRIPTORS = 0x00800000u,
MH_NO_HEAP_EXECUTION = 0x01000000u,
- MH_APP_EXTENSION_SAFE = 0x02000000u
+ MH_APP_EXTENSION_SAFE = 0x02000000u,
+ MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x04000000u
};
enum : uint32_t {
diff --git a/include/llvm/BinaryFormat/Wasm.h b/include/llvm/BinaryFormat/Wasm.h
index fcd8ad957040..470c20ddc7d9 100644
--- a/include/llvm/BinaryFormat/Wasm.h
+++ b/include/llvm/BinaryFormat/Wasm.h
@@ -176,6 +176,11 @@ enum class ValType {
// Linking metadata kinds.
enum : unsigned {
WASM_STACK_POINTER = 0x1,
+ WASM_SYMBOL_INFO = 0x2,
+};
+
+enum : unsigned {
+ WASM_SYMBOL_FLAG_WEAK = 0x1,
};
#define WASM_RELOC(name, value) name = value,
diff --git a/include/llvm/CodeGen/DIE.h b/include/llvm/CodeGen/DIE.h
index 5ed5faa2c415..f809fc97fe59 100644
--- a/include/llvm/CodeGen/DIE.h
+++ b/include/llvm/CodeGen/DIE.h
@@ -121,8 +121,8 @@ public:
/// Print the abbreviation using the specified asm printer.
void Emit(const AsmPrinter *AP) const;
- void print(raw_ostream &O);
- void dump();
+ void print(raw_ostream &O) const;
+ void dump() const;
};
//===--------------------------------------------------------------------===//
@@ -780,7 +780,7 @@ public:
DIEValue findAttribute(dwarf::Attribute Attribute) const;
void print(raw_ostream &O, unsigned IndentCount = 0) const;
- void dump();
+ void dump() const;
};
//===--------------------------------------------------------------------===//
diff --git a/include/llvm/CodeGen/GlobalISel/InstructionSelector.h b/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
index 1a865c3f0dce..b3ef7c2dc185 100644
--- a/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
+++ b/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
@@ -29,6 +29,7 @@ class MachineOperand;
class MachineRegisterInfo;
class RegisterBankInfo;
class TargetInstrInfo;
+class TargetRegisterClass;
class TargetRegisterInfo;
/// Container class for CodeGen predicate results.
@@ -79,6 +80,16 @@ protected:
InstructionSelector();
+ /// Constrain a register operand of an instruction \p I to a specified
+ /// register class. This could involve inserting COPYs before (for uses) or
+ /// after (for defs) and may replace the operand of \p I.
+ /// \returns whether operand regclass constraining succeeded.
+ bool constrainOperandRegToRegClass(MachineInstr &I, unsigned OpIdx,
+ const TargetRegisterClass &RC,
+ const TargetInstrInfo &TII,
+ const TargetRegisterInfo &TRI,
+ const RegisterBankInfo &RBI) const;
+
/// Mutate the newly-selected instruction \p I to constrain its (possibly
/// generic) virtual register operands to the instruction's register class.
/// This could involve inserting COPYs before (for uses) or after (for defs).
diff --git a/include/llvm/CodeGen/GlobalISel/Legalizer.h b/include/llvm/CodeGen/GlobalISel/Legalizer.h
index bed7230cc013..9b9b8b563a30 100644
--- a/include/llvm/CodeGen/GlobalISel/Legalizer.h
+++ b/include/llvm/CodeGen/GlobalISel/Legalizer.h
@@ -59,7 +59,7 @@ public:
const TargetInstrInfo &TII);
bool combineMerges(MachineInstr &MI, MachineRegisterInfo &MRI,
- const TargetInstrInfo &TII);
+ const TargetInstrInfo &TII, MachineIRBuilder &MIRBuilder);
bool runOnMachineFunction(MachineFunction &MF) override;
};
diff --git a/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h b/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
index 4e7b8350038b..c9327d50432e 100644
--- a/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
+++ b/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
@@ -471,10 +471,12 @@ public:
/// Build and insert \p Res = IMPLICIT_DEF.
MachineInstrBuilder buildUndef(unsigned Dst);
- /// Build and insert \p Res<def> = G_SEQUENCE \p Op0, \p Idx0...
+ /// Build and insert instructions to put \p Ops together at the specified p
+ /// Indices to form a larger register.
///
- /// G_SEQUENCE inserts each element of Ops into an IMPLICIT_DEF register,
- /// where each entry starts at the bit-index specified by \p Indices.
+ /// If the types of the input registers are uniform and cover the entirity of
+ /// \p Res then a G_MERGE_VALUES will be produced. Otherwise an IMPLICIT_DEF
+ /// followed by a sequence of G_INSERT instructions.
///
/// \pre setBasicBlock or setMI must have been called.
/// \pre The final element of the sequence must not extend past the end of the
@@ -482,11 +484,8 @@ public:
/// \pre The bits defined by each Op (derived from index and scalar size) must
/// not overlap.
/// \pre \p Indices must be in ascending order of bit position.
- ///
- /// \return a MachineInstrBuilder for the newly created instruction.
- MachineInstrBuilder buildSequence(unsigned Res,
- ArrayRef<unsigned> Ops,
- ArrayRef<uint64_t> Indices);
+ void buildSequence(unsigned Res, ArrayRef<unsigned> Ops,
+ ArrayRef<uint64_t> Indices);
/// Build and insert \p Res<def> = G_MERGE_VALUES \p Op0, ...
///
@@ -513,24 +512,6 @@ public:
/// \return a MachineInstrBuilder for the newly created instruction.
MachineInstrBuilder buildUnmerge(ArrayRef<unsigned> Res, unsigned Op);
- void addUsesWithIndices(MachineInstrBuilder MIB) {}
-
- template <typename... ArgTys>
- void addUsesWithIndices(MachineInstrBuilder MIB, unsigned Reg,
- unsigned BitIndex, ArgTys... Args) {
- MIB.addUse(Reg).addImm(BitIndex);
- addUsesWithIndices(MIB, Args...);
- }
-
- template <typename... ArgTys>
- MachineInstrBuilder buildSequence(unsigned Res, unsigned Op,
- unsigned Index, ArgTys... Args) {
- MachineInstrBuilder MIB =
- buildInstr(TargetOpcode::G_SEQUENCE).addDef(Res);
- addUsesWithIndices(MIB, Op, Index, Args...);
- return MIB;
- }
-
MachineInstrBuilder buildInsert(unsigned Res, unsigned Src,
unsigned Op, unsigned Index);
diff --git a/include/llvm/CodeGen/GlobalISel/Utils.h b/include/llvm/CodeGen/GlobalISel/Utils.h
index 69d507069808..50ddbeb9432a 100644
--- a/include/llvm/CodeGen/GlobalISel/Utils.h
+++ b/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -29,13 +29,26 @@ class RegisterBankInfo;
class TargetInstrInfo;
class TargetPassConfig;
class TargetRegisterInfo;
+class TargetRegisterClass;
class Twine;
class ConstantFP;
+/// Try to constrain Reg to the specified register class. If this fails,
+/// create a new virtual register in the correct class and insert a COPY before
+/// \p InsertPt. The debug location of \p InsertPt is used for the new copy.
+///
+/// \return The virtual register constrained to the right register class.
+unsigned constrainRegToClass(MachineRegisterInfo &MRI,
+ const TargetInstrInfo &TII,
+ const RegisterBankInfo &RBI,
+ MachineInstr &InsertPt, unsigned Reg,
+ const TargetRegisterClass &RegClass);
+
/// Try to constrain Reg so that it is usable by argument OpIdx of the
/// provided MCInstrDesc \p II. If this fails, create a new virtual
/// register in the correct class and insert a COPY before \p InsertPt.
-/// The debug location of \p InsertPt is used for the new copy.
+/// This is equivalent to constrainRegToClass() with RegClass obtained from the
+/// MCInstrDesc. The debug location of \p InsertPt is used for the new copy.
///
/// \return The virtual register constrained to the right register class.
unsigned constrainOperandRegClass(const MachineFunction &MF,
diff --git a/include/llvm/CodeGen/LexicalScopes.h b/include/llvm/CodeGen/LexicalScopes.h
index 79fa12ec2fbb..3ba503487823 100644
--- a/include/llvm/CodeGen/LexicalScopes.h
+++ b/include/llvm/CodeGen/LexicalScopes.h
@@ -196,7 +196,7 @@ public:
}
/// dump - Print data structures to dbgs().
- void dump();
+ void dump() const;
/// getOrCreateAbstractScope - Find or create an abstract lexical scope.
LexicalScope *getOrCreateAbstractScope(const DILocalScope *Scope);
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h
index 051908c40df7..97a49ce4dc4f 100644
--- a/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/include/llvm/CodeGen/MachineBasicBlock.h
@@ -376,6 +376,9 @@ public:
/// Indicates if this is the entry block of a cleanup funclet.
void setIsCleanupFuncletEntry(bool V = true) { IsCleanupFuncletEntry = V; }
+ /// Returns true if it is legal to hoist instructions into this block.
+ bool isLegalToHoistInto() const;
+
// Code Layout methods.
/// Move 'this' block before or after the specified block. This only moves
diff --git a/include/llvm/CodeGen/MachineMemOperand.h b/include/llvm/CodeGen/MachineMemOperand.h
index 4d83f27eac3c..78adce507b8c 100644
--- a/include/llvm/CodeGen/MachineMemOperand.h
+++ b/include/llvm/CodeGen/MachineMemOperand.h
@@ -59,6 +59,11 @@ struct MachinePointerInfo {
return MachinePointerInfo(V.get<const PseudoSourceValue*>(), Offset+O);
}
+ /// Return true if memory region [V, V+Offset+Size) is known to be
+ /// dereferenceable.
+ bool isDereferenceable(unsigned Size, LLVMContext &C,
+ const DataLayout &DL) const;
+
/// Return the LLVM IR address space number that this pointer points into.
unsigned getAddrSpace() const;
diff --git a/include/llvm/CodeGen/MachineModuleInfoImpls.h b/include/llvm/CodeGen/MachineModuleInfoImpls.h
index 61cff3890b75..34b21ceddd43 100644
--- a/include/llvm/CodeGen/MachineModuleInfoImpls.h
+++ b/include/llvm/CodeGen/MachineModuleInfoImpls.h
@@ -77,33 +77,6 @@ public:
SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
};
-/// MachineModuleInfoWasm - This is a MachineModuleInfoImpl implementation
-/// for Wasm targets.
-class MachineModuleInfoWasm : public MachineModuleInfoImpl {
- /// WebAssembly global variables defined by CodeGen.
- std::vector<wasm::Global> Globals;
-
- /// The WebAssembly global variable which is the stack pointer.
- unsigned StackPointerGlobal;
-
- virtual void anchor(); // Out of line virtual method.
-public:
- MachineModuleInfoWasm(const MachineModuleInfo &)
- : StackPointerGlobal(-1U) {}
-
- void addGlobal(const wasm::Global &G) { Globals.push_back(G); }
- const std::vector<wasm::Global> &getGlobals() const { return Globals; }
-
- bool hasStackPointerGlobal() const {
- return StackPointerGlobal != -1U;
- }
- unsigned getStackPointerGlobal() const {
- assert(hasStackPointerGlobal() && "Stack ptr global hasn't been set");
- return StackPointerGlobal;
- }
- void setStackPointerGlobal(unsigned Global) { StackPointerGlobal = Global; }
-};
-
} // end namespace llvm
#endif
diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h
index 3b02ec400aba..34cbffa78203 100644
--- a/include/llvm/CodeGen/MachineScheduler.h
+++ b/include/llvm/CodeGen/MachineScheduler.h
@@ -203,7 +203,7 @@ public:
MachineBasicBlock::iterator End,
unsigned NumRegionInstrs) {}
- virtual void dumpPolicy() {}
+ virtual void dumpPolicy() const {}
/// Check if pressure tracking is needed before building the DAG and
/// initializing this strategy. Called after initPolicy.
@@ -555,7 +555,7 @@ public:
return Queue.begin() + idx;
}
- void dump();
+ void dump() const;
};
/// Summarize the unscheduled region.
@@ -756,7 +756,7 @@ public:
SUnit *pickOnlyChoice();
#ifndef NDEBUG
- void dumpScheduledState();
+ void dumpScheduledState() const;
#endif
};
@@ -890,7 +890,7 @@ public:
MachineBasicBlock::iterator End,
unsigned NumRegionInstrs) override;
- void dumpPolicy() override;
+ void dumpPolicy() const override;
bool shouldTrackPressure() const override {
return RegionPolicy.ShouldTrackPressure;
diff --git a/include/llvm/CodeGen/MacroFusion.h b/include/llvm/CodeGen/MacroFusion.h
new file mode 100644
index 000000000000..473784bc5841
--- /dev/null
+++ b/include/llvm/CodeGen/MacroFusion.h
@@ -0,0 +1,41 @@
+//===- MacroFusion.h - Macro Fusion ------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file This file contains the definition of the DAG scheduling mutation to
+/// pair instructions back to back.
+//
+//===----------------------------------------------------------------------===//
+
+#include <functional>
+#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/CodeGen/MachineScheduler.h"
+
+namespace llvm {
+
+/// \brief Check if the instr pair, FirstMI and SecondMI, should be fused
+/// together. Given SecondMI, when FirstMI is unspecified, then check if
+/// SecondMI may be part of a fused pair at all.
+typedef std::function<bool(const TargetInstrInfo &TII,
+ const TargetSubtargetInfo &TSI,
+ const MachineInstr *FirstMI,
+ const MachineInstr &SecondMI)> ShouldSchedulePredTy;
+
+/// \brief Create a DAG scheduling mutation to pair instructions back to back
+/// for instructions that benefit according to the target-specific
+/// shouldScheduleAdjacent predicate function.
+std::unique_ptr<ScheduleDAGMutation>
+createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
+
+/// \brief Create a DAG scheduling mutation to pair branch instructions with one
+/// of their predecessors back to back for instructions that benefit according
+/// to the target-specific shouldScheduleAdjacent predicate function.
+std::unique_ptr<ScheduleDAGMutation>
+createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
+
+} // end namespace llvm
diff --git a/include/llvm/CodeGen/RegisterScavenging.h b/include/llvm/CodeGen/RegisterScavenging.h
index ad1efe18c72d..489c72b81a98 100644
--- a/include/llvm/CodeGen/RegisterScavenging.h
+++ b/include/llvm/CodeGen/RegisterScavenging.h
@@ -156,12 +156,24 @@ public:
/// available and do the appropriate bookkeeping. SPAdj is the stack
/// adjustment due to call frame, it's passed along to eliminateFrameIndex().
/// Returns the scavenged register.
+ /// This is deprecated as it depends on the quality of the kill flags being
+ /// present; Use scavengeRegisterBackwards() instead!
unsigned scavengeRegister(const TargetRegisterClass *RegClass,
MachineBasicBlock::iterator I, int SPAdj);
unsigned scavengeRegister(const TargetRegisterClass *RegClass, int SPAdj) {
return scavengeRegister(RegClass, MBBI, SPAdj);
}
+ /// Make a register of the specific register class available from the current
+ /// position backwards to the place before \p To. If \p RestoreAfter is true
+ /// this includes the instruction following the current position.
+ /// SPAdj is the stack adjustment due to call frame, it's passed along to
+ /// eliminateFrameIndex().
+ /// Returns the scavenged register.
+ unsigned scavengeRegisterBackwards(const TargetRegisterClass &RC,
+ MachineBasicBlock::iterator To,
+ bool RestoreAfter, int SPAdj);
+
/// Tell the scavenger a register is used.
void setRegUsed(unsigned Reg, LaneBitmask LaneMask = LaneBitmask::getAll());
@@ -202,6 +214,12 @@ private:
/// Mark live-in registers of basic block as used.
void setLiveInsUsed(const MachineBasicBlock &MBB);
+
+ /// Spill a register after position \p After and reload it before position
+ /// \p UseMI.
+ ScavengedInfo &spill(unsigned Reg, const TargetRegisterClass &RC, int SPAdj,
+ MachineBasicBlock::iterator After,
+ MachineBasicBlock::iterator &UseMI);
};
/// Replaces all frame index virtual registers with physical registers. Uses the
diff --git a/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h b/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
new file mode 100644
index 000000000000..d82ab7d647e7
--- /dev/null
+++ b/include/llvm/CodeGen/SelectionDAGAddressAnalysis.h
@@ -0,0 +1,64 @@
+//===-- llvm/CodeGen/SelectionDAGAddressAnalysis.h ------- DAG Address Analysis
+//---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+
+#ifndef LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
+#define LLVM_CODEGEN_SELECTIONDAGADDRESSANALYSIS_H
+
+#include "llvm/CodeGen/ISDOpcodes.h"
+#include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/CodeGen/SelectionDAGNodes.h"
+
+namespace llvm {
+/// Helper struct to parse and store a memory address as base + index + offset.
+/// We ignore sign extensions when it is safe to do so.
+/// The following two expressions are not equivalent. To differentiate we need
+/// to store whether there was a sign extension involved in the index
+/// computation.
+/// (load (i64 add (i64 copyfromreg %c)
+/// (i64 signextend (add (i8 load %index)
+/// (i8 1))))
+/// vs
+///
+/// (load (i64 add (i64 copyfromreg %c)
+/// (i64 signextend (i32 add (i32 signextend (i8 load %index))
+/// (i32 1)))))
+class BaseIndexOffset {
+private:
+ SDValue Base;
+ SDValue Index;
+ int64_t Offset;
+ bool IsIndexSignExt;
+
+public:
+ BaseIndexOffset() : Offset(0), IsIndexSignExt(false) {}
+
+ BaseIndexOffset(SDValue Base, SDValue Index, int64_t Offset,
+ bool IsIndexSignExt)
+ : Base(Base), Index(Index), Offset(Offset),
+ IsIndexSignExt(IsIndexSignExt) {}
+
+ SDValue getBase() { return Base; }
+ SDValue getIndex() { return Index; }
+
+ bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG) {
+ int64_t Off;
+ return equalBaseIndex(Other, DAG, Off);
+ }
+
+ bool equalBaseIndex(BaseIndexOffset &Other, const SelectionDAG &DAG,
+ int64_t &Off);
+
+ /// Parses tree in Ptr for base, index, offset addresses.
+ static BaseIndexOffset match(SDValue Ptr);
+};
+} // namespace llvm
+
+#endif
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index 0cd26d35a482..af418d3050e4 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -2107,7 +2107,7 @@ class MaskedGatherScatterSDNode : public MemSDNode {
public:
friend class SelectionDAG;
- MaskedGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order,
+ MaskedGatherScatterSDNode(unsigned NodeTy, unsigned Order,
const DebugLoc &dl, SDVTList VTs, EVT MemVT,
MachineMemOperand *MMO)
: MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {}
diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake
index 8df15ef97026..1289551f0739 100644
--- a/include/llvm/Config/config.h.cmake
+++ b/include/llvm/Config/config.h.cmake
@@ -356,6 +356,9 @@
/* Define if this is Win32ish platform */
#cmakedefine LLVM_ON_WIN32 ${LLVM_ON_WIN32}
+/* Define if overriding target triple is enabled */
+#cmakedefine LLVM_TARGET_TRIPLE_ENV "${LLVM_TARGET_TRIPLE_ENV}"
+
/* Define if we have the Intel JIT API runtime support library */
#cmakedefine01 LLVM_USE_INTEL_JITEVENTS
diff --git a/include/llvm/DebugInfo/CodeView/CVRecord.h b/include/llvm/DebugInfo/CodeView/CVRecord.h
index 4c6bbedc6bbd..44040e04388a 100644
--- a/include/llvm/DebugInfo/CodeView/CVRecord.h
+++ b/include/llvm/DebugInfo/CodeView/CVRecord.h
@@ -27,9 +27,12 @@ namespace codeview {
template <typename Kind> class CVRecord {
public:
- CVRecord() = default;
+ CVRecord() : Type(static_cast<Kind>(0)) {}
+
CVRecord(Kind K, ArrayRef<uint8_t> Data) : Type(K), RecordData(Data) {}
+ bool valid() const { return Type != static_cast<Kind>(0); }
+
uint32_t length() const { return RecordData.size(); }
Kind kind() const { return Type; }
ArrayRef<uint8_t> data() const { return RecordData; }
diff --git a/include/llvm/DebugInfo/CodeView/CodeView.h b/include/llvm/DebugInfo/CodeView/CodeView.h
index 6820e26b754c..b7a7e33abadf 100644
--- a/include/llvm/DebugInfo/CodeView/CodeView.h
+++ b/include/llvm/DebugInfo/CodeView/CodeView.h
@@ -402,6 +402,16 @@ enum class LocalSymFlags : uint16_t {
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
+/// Corresponds to the CV_PUBSYMFLAGS bitfield.
+enum class PublicSymFlags : uint32_t {
+ None = 0,
+ Code = 1 << 0,
+ Function = 1 << 1,
+ Managed = 1 << 2,
+ MSIL = 1 << 3,
+};
+CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags)
+
/// Corresponds to the CV_PROCFLAGS bitfield.
enum class ProcSymFlags : uint8_t {
None = 0,
diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h
index 694731742064..ee17b47d8e63 100644
--- a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h
+++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h
@@ -51,11 +51,23 @@ class DebugSubsectionRecordBuilder {
public:
DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection,
CodeViewContainer Container);
+
+ /// Use this to copy existing subsections directly from source to destination.
+ /// For example, line table subsections in an object file only need to be
+ /// relocated before being copied into the PDB.
+ DebugSubsectionRecordBuilder(const DebugSubsectionRecord &Contents,
+ CodeViewContainer Container);
+
uint32_t calculateSerializedLength();
Error commit(BinaryStreamWriter &Writer) const;
private:
+ /// The subsection to build. Will be null if Contents is non-empty.
std::shared_ptr<DebugSubsection> Subsection;
+
+ /// The bytes of the subsection. Only non-empty if Subsection is null.
+ DebugSubsectionRecord Contents;
+
CodeViewContainer Container;
};
diff --git a/include/llvm/DebugInfo/CodeView/EnumTables.h b/include/llvm/DebugInfo/CodeView/EnumTables.h
index 013e440613fc..5d54bb4cca84 100644
--- a/include/llvm/DebugInfo/CodeView/EnumTables.h
+++ b/include/llvm/DebugInfo/CodeView/EnumTables.h
@@ -22,6 +22,7 @@ namespace codeview {
ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames();
ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames();
ArrayRef<EnumEntry<uint16_t>> getRegisterNames();
+ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames();
ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames();
ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames();
ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames();
diff --git a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
index 0d056e42b45f..8b1540abf903 100644
--- a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
+++ b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h
@@ -11,18 +11,15 @@
#define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H
#include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
+#include "llvm/Support/Allocator.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/StringSaver.h"
namespace llvm {
namespace codeview {
-class TypeDatabase;
-class TypeVisitorCallbacks;
-
/// \brief Provides amortized O(1) random access to a CodeView type stream.
/// Normally to access a type from a type stream, you must know its byte
/// offset into the type stream, because type records are variable-lengthed.
@@ -47,6 +44,11 @@ class TypeVisitorCallbacks;
/// of O(N/M) and an amortized time of O(1).
class LazyRandomTypeCollection : public TypeCollection {
typedef FixedStreamArray<TypeIndexOffset> PartialOffsetArray;
+ struct CacheEntry {
+ CVType Type;
+ uint32_t Offset;
+ StringRef Name;
+ };
public:
explicit LazyRandomTypeCollection(uint32_t RecordCountHint);
@@ -56,8 +58,10 @@ public:
PartialOffsetArray PartialOffsets);
LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint);
- void reset(ArrayRef<uint8_t> Data);
- void reset(StringRef Data);
+ void reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint);
+ void reset(StringRef Data, uint32_t RecordCountHint);
+
+ uint32_t getOffsetOfType(TypeIndex Index);
CVType getType(TypeIndex Index) override;
StringRef getTypeName(TypeIndex Index) override;
@@ -68,27 +72,26 @@ public:
Optional<TypeIndex> getNext(TypeIndex Prev) override;
private:
- const TypeDatabase &database() const { return Database; }
Error ensureTypeExists(TypeIndex Index);
+ void ensureCapacityFor(TypeIndex Index);
Error visitRangeForType(TypeIndex TI);
Error fullScanForType(TypeIndex TI);
- Error visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End);
- Error visitOneRecord(TypeIndex TI, uint32_t Offset, CVType &Record);
+ void visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End);
+
+ /// Number of actual records.
+ uint32_t Count = 0;
- /// Visited records get automatically added to the type database.
- TypeDatabase Database;
+ /// The largest type index which we've visited.
+ TypeIndex LargestTypeIndex = TypeIndex::None();
+
+ BumpPtrAllocator Allocator;
+ StringSaver NameStorage;
/// The type array to allow random access visitation of.
CVTypeArray Types;
- /// The database visitor which adds new records to the database.
- TypeDatabaseVisitor DatabaseVisitor;
-
- /// A vector mapping type indices to type offset. For every record that has
- /// been visited, contains the absolute offset of that record in the record
- /// array.
- std::vector<uint32_t> KnownOffsets;
+ std::vector<CacheEntry> Records;
/// An array of index offsets for the given type stream, allowing log(N)
/// lookups of a type record by index. Similar to KnownOffsets but only
diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h
index 5f85ed28cb3a..1cf77fcdecbe 100644
--- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h
+++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h
@@ -363,7 +363,7 @@ public:
: SymbolRecord(SymbolRecordKind::PublicSym32),
RecordOffset(RecordOffset) {}
- TypeIndex Index;
+ PublicSymFlags Flags;
uint32_t Offset;
uint16_t Segment;
StringRef Name;
diff --git a/include/llvm/DebugInfo/CodeView/TypeDatabase.h b/include/llvm/DebugInfo/CodeView/TypeDatabase.h
deleted file mode 100644
index a743e7f70855..000000000000
--- a/include/llvm/DebugInfo/CodeView/TypeDatabase.h
+++ /dev/null
@@ -1,84 +0,0 @@
-//===- TypeDatabase.h - A collection of CodeView type records ---*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASE_H
-#define LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASE_H
-
-#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/Support/Allocator.h"
-#include "llvm/Support/StringSaver.h"
-
-namespace llvm {
-namespace codeview {
-class TypeDatabase : public TypeCollection {
- friend class RandomAccessTypeVisitor;
-
-public:
- explicit TypeDatabase(uint32_t Capacity);
-
- /// Records the name of a type, and reserves its type index.
- TypeIndex appendType(StringRef Name, const CVType &Data);
-
- /// Records the name of a type, and reserves its type index.
- void recordType(StringRef Name, TypeIndex Index, const CVType &Data);
-
- /// Saves the name in a StringSet and creates a stable StringRef.
- StringRef saveTypeName(StringRef TypeName);
-
- StringRef getTypeName(TypeIndex Index) const;
-
- const CVType &getTypeRecord(TypeIndex Index) const;
- CVType &getTypeRecord(TypeIndex Index);
-
- bool contains(TypeIndex Index) const;
- uint32_t size() const;
- uint32_t capacity() const;
- bool empty() const;
-
- CVType getType(TypeIndex Index) override;
- StringRef getTypeName(TypeIndex Index) override;
- bool contains(TypeIndex Index) override;
- uint32_t size() override;
- uint32_t capacity() override;
-
- Optional<TypeIndex> getFirst() override;
- Optional<TypeIndex> getNext(TypeIndex Prev) override;
-
- Optional<TypeIndex> largestTypeIndexLessThan(TypeIndex TI) const;
-
-private:
- TypeIndex getAppendIndex() const;
-
- void grow();
- void grow(TypeIndex Index);
-
- BumpPtrAllocator Allocator;
-
- uint32_t Count = 0;
- TypeIndex LargestTypeIndex;
-
- /// All user defined type records in .debug$T live in here. Type indices
- /// greater than 0x1000 are user defined. Subtract 0x1000 from the index to
- /// index into this vector.
- SmallVector<StringRef, 10> CVUDTNames;
- SmallVector<CVType, 10> TypeRecords;
-
- StringSaver TypeNameStorage;
-
- BitVector ValidRecords;
-};
-}
-}
-
-#endif \ No newline at end of file
diff --git a/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h b/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h
deleted file mode 100644
index 77dbc91a7d38..000000000000
--- a/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//===-- TypeDatabaseVisitor.h -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASEVISITOR_H
-#define LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASEVISITOR_H
-
-#include "llvm/ADT/PointerUnion.h"
-
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-
-namespace llvm {
-namespace codeview {
-
-/// Dumper for CodeView type streams found in COFF object files and PDB files.
-class TypeDatabaseVisitor : public TypeVisitorCallbacks {
-public:
- explicit TypeDatabaseVisitor(TypeDatabase &TypeDB) : TypeDB(&TypeDB) {}
-
- /// Paired begin/end actions for all types. Receives all record data,
- /// including the fixed-length record prefix.
- Error visitTypeBegin(CVType &Record) override;
- Error visitTypeBegin(CVType &Record, TypeIndex Index) override;
- Error visitTypeEnd(CVType &Record) override;
- Error visitMemberBegin(CVMemberRecord &Record) override;
- Error visitMemberEnd(CVMemberRecord &Record) override;
-
-#define TYPE_RECORD(EnumName, EnumVal, Name) \
- Error visitKnownRecord(CVType &CVR, Name##Record &Record) override;
-#define MEMBER_RECORD(EnumName, EnumVal, Name) \
- Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override;
-#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
-#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
-
-private:
- StringRef getTypeName(TypeIndex Index) const;
- StringRef saveTypeName(StringRef Name);
-
- bool IsInFieldList = false;
-
- /// Name of the current type. Only valid before visitTypeEnd.
- StringRef Name;
- /// Current type index. Only valid before visitTypeEnd, and if we are
- /// visiting a random access type database.
- Optional<TypeIndex> CurrentTypeIndex;
-
- TypeDatabase *TypeDB;
-};
-
-} // end namespace codeview
-} // end namespace llvm
-
-#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H
diff --git a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h
index 82ceb5038316..c393b42cd27c 100644
--- a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h
+++ b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h
@@ -11,6 +11,7 @@
#define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H
#include "llvm/ADT/SmallVector.h"
+#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/Support/Error.h"
@@ -27,6 +28,11 @@ void discoverTypeIndices(ArrayRef<uint8_t> RecordData,
SmallVectorImpl<TiReference> &Refs);
void discoverTypeIndices(const CVType &Type,
SmallVectorImpl<TiReference> &Refs);
+
+/// Discover type indices in symbol records. Returns false if this is an unknown
+/// record.
+bool discoverTypeIndices(const CVSymbol &Symbol,
+ SmallVectorImpl<TiReference> &Refs);
}
}
diff --git a/include/llvm/DebugInfo/CodeView/TypeName.h b/include/llvm/DebugInfo/CodeView/TypeName.h
new file mode 100644
index 000000000000..a987b4afd283
--- /dev/null
+++ b/include/llvm/DebugInfo/CodeView/TypeName.h
@@ -0,0 +1,22 @@
+//===- TypeName.h --------------------------------------------- *- C++ --*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H
+#define LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H
+
+#include "llvm/DebugInfo/CodeView/TypeCollection.h"
+#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+
+namespace llvm {
+namespace codeview {
+std::string computeTypeName(TypeCollection &Types, TypeIndex Index);
+}
+} // namespace llvm
+
+#endif
diff --git a/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h b/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
index 6156223b2560..cbe8d6066bb9 100644
--- a/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
+++ b/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h
@@ -25,6 +25,7 @@ public:
explicit TypeRecordMapping(BinaryStreamReader &Reader) : IO(Reader) {}
explicit TypeRecordMapping(BinaryStreamWriter &Writer) : IO(Writer) {}
+ using TypeVisitorCallbacks::visitTypeBegin;
Error visitTypeBegin(CVType &Record) override;
Error visitTypeEnd(CVType &Record) override;
diff --git a/include/llvm/DebugInfo/CodeView/TypeSerializer.h b/include/llvm/DebugInfo/CodeView/TypeSerializer.h
index f785d4509547..988a2d4aa834 100644
--- a/include/llvm/DebugInfo/CodeView/TypeSerializer.h
+++ b/include/llvm/DebugInfo/CodeView/TypeSerializer.h
@@ -93,6 +93,7 @@ public:
TypeIndex insertRecord(const RemappedType &Record);
Expected<TypeIndex> visitTypeEndGetIndex(CVType &Record);
+ using TypeVisitorCallbacks::visitTypeBegin;
Error visitTypeBegin(CVType &Record) override;
Error visitTypeEnd(CVType &Record) override;
Error visitMemberBegin(CVMemberRecord &Record) override;
diff --git a/include/llvm/DebugInfo/CodeView/TypeTableCollection.h b/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
index 42b62ba2b6ce..80326a0ffd39 100644
--- a/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
+++ b/include/llvm/DebugInfo/CodeView/TypeTableCollection.h
@@ -11,7 +11,9 @@
#define LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H
#include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
+#include "llvm/Support/StringSaver.h"
+
+#include <vector>
namespace llvm {
namespace codeview {
@@ -30,11 +32,10 @@ public:
uint32_t capacity() override;
private:
- bool hasCapacityFor(TypeIndex Index) const;
- void ensureTypeExists(TypeIndex Index);
-
+ BumpPtrAllocator Allocator;
+ StringSaver NameStorage;
+ std::vector<StringRef> Names;
ArrayRef<ArrayRef<uint8_t>> Records;
- TypeDatabase Database;
};
}
}
diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h
index 2e82a774cc23..4126e245ff13 100644
--- a/include/llvm/DebugInfo/DIContext.h
+++ b/include/llvm/DebugInfo/DIContext.h
@@ -57,7 +57,7 @@ struct DILineInfo {
}
};
-typedef SmallVector<std::pair<uint64_t, DILineInfo>, 16> DILineInfoTable;
+using DILineInfoTable = SmallVector<std::pair<uint64_t, DILineInfo>, 16>;
/// DIInliningInfo - a format-neutral container for inlined code description.
class DIInliningInfo {
@@ -102,7 +102,7 @@ enum class DINameKind { None, ShortName, LinkageName };
/// should be filled with data.
struct DILineInfoSpecifier {
enum class FileLineInfoKind { None, Default, AbsoluteFilePath };
- typedef DINameKind FunctionNameKind;
+ using FunctionNameKind = DINameKind;
FileLineInfoKind FLIKind;
FunctionNameKind FNKind;
@@ -174,6 +174,7 @@ public:
// No verifier? Just say things went well.
return true;
}
+
virtual DILineInfo getLineInfoForAddress(uint64_t Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
virtual DILineInfoTable getLineInfoForAddressRange(uint64_t Address,
diff --git a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
index e363cff15803..190a69b75739 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h
@@ -33,6 +33,7 @@ public:
dwarf::Attribute Attr;
dwarf::Form Form;
+
/// The following field is used for ByteSize for non-implicit_const
/// attributes and as value for implicit_const ones, indicated by
/// Form == DW_FORM_implicit_const.
@@ -58,7 +59,7 @@ public:
/// the ByteSize member.
Optional<int64_t> getByteSize(const DWARFUnit &U) const;
};
- typedef SmallVector<AttributeSpec, 8> AttributeSpecVector;
+ using AttributeSpecVector = SmallVector<AttributeSpec, 8>;
DWARFAbbreviationDeclaration();
@@ -67,8 +68,8 @@ public:
dwarf::Tag getTag() const { return Tag; }
bool hasChildren() const { return HasChildren; }
- typedef iterator_range<AttributeSpecVector::const_iterator>
- attr_iterator_range;
+ using attr_iterator_range =
+ iterator_range<AttributeSpecVector::const_iterator>;
attr_iterator_range attributes() const {
return attr_iterator_range(AttributeSpecs.begin(), AttributeSpecs.end());
diff --git a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
index 3012b39dcc52..8bde63efe188 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -32,8 +32,9 @@ class DWARFAcceleratorTable {
};
struct HeaderData {
- typedef uint16_t AtomType;
- typedef dwarf::Form Form;
+ using AtomType = uint16_t;
+ using Form = dwarf::Form;
+
uint32_t DIEOffsetBase;
SmallVector<std::pair<AtomType, Form>, 3> Atoms;
};
diff --git a/include/llvm/DebugInfo/DWARF/DWARFContext.h b/include/llvm/DebugInfo/DWARF/DWARFContext.h
index c72604a12bfd..4bf34d52bcba 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -10,7 +10,6 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
#define LLVM_DEBUGINFO_DWARF_DWARFCONTEXT_H
-#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
@@ -25,21 +24,24 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
+#include "llvm/DebugInfo/DWARF/DWARFDie.h"
#include "llvm/DebugInfo/DWARF/DWARFGdbIndex.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
+#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/Host.h"
#include <cstdint>
#include <deque>
#include <map>
#include <memory>
-#include <utility>
namespace llvm {
+class DataExtractor;
class MemoryBuffer;
class raw_ostream;
@@ -73,7 +75,7 @@ class DWARFContext : public DIContext {
std::unique_ptr<DWARFDebugLocDWO> LocDWO;
/// The maximum DWARF version of all units.
- unsigned MaxVersion;
+ unsigned MaxVersion = 0;
struct DWOFile {
object::OwningBinary<object::ObjectFile> File;
@@ -100,7 +102,7 @@ class DWARFContext : public DIContext {
void parseDWOTypeUnits();
public:
- DWARFContext() : DIContext(CK_DWARF), MaxVersion(0) {}
+ DWARFContext() : DIContext(CK_DWARF) {}
DWARFContext(DWARFContext &) = delete;
DWARFContext &operator=(DWARFContext &) = delete;
@@ -112,9 +114,9 @@ public:
bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override;
- typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range;
- typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range;
- typedef iterator_range<decltype(TUs)::iterator> tu_section_iterator_range;
+ using cu_iterator_range = DWARFUnitSection<DWARFCompileUnit>::iterator_range;
+ using tu_iterator_range = DWARFUnitSection<DWARFTypeUnit>::iterator_range;
+ using tu_section_iterator_range = iterator_range<decltype(TUs)::iterator>;
/// Get compile units in this context.
cu_iterator_range compile_units() {
@@ -230,8 +232,10 @@ public:
virtual bool isLittleEndian() const = 0;
virtual uint8_t getAddressSize() const = 0;
virtual const DWARFSection &getInfoSection() = 0;
- typedef MapVector<object::SectionRef, DWARFSection,
- std::map<object::SectionRef, unsigned>> TypeSectionMap;
+
+ using TypeSectionMap = MapVector<object::SectionRef, DWARFSection,
+ std::map<object::SectionRef, unsigned>>;
+
virtual const TypeSectionMap &getTypesSections() = 0;
virtual StringRef getAbbrevSection() = 0;
virtual const DWARFSection &getLocSection() = 0;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
index 9f86fe508389..65571598d743 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
@@ -18,6 +18,8 @@
namespace llvm {
+class raw_ostream;
+
class DWARFAbbreviationDeclarationSet {
uint32_t Offset;
/// Code of the first abbreviation, if all abbreviations in the set have
@@ -25,8 +27,8 @@ class DWARFAbbreviationDeclarationSet {
uint32_t FirstAbbrCode;
std::vector<DWARFAbbreviationDeclaration> Decls;
- typedef std::vector<DWARFAbbreviationDeclaration>::const_iterator
- const_iterator;
+ using const_iterator =
+ std::vector<DWARFAbbreviationDeclaration>::const_iterator;
public:
DWARFAbbreviationDeclarationSet();
@@ -51,8 +53,8 @@ private:
};
class DWARFDebugAbbrev {
- typedef std::map<uint64_t, DWARFAbbreviationDeclarationSet>
- DWARFAbbreviationDeclarationSetMap;
+ using DWARFAbbreviationDeclarationSetMap =
+ std::map<uint64_t, DWARFAbbreviationDeclarationSet>;
DWARFAbbreviationDeclarationSetMap AbbrDeclSets;
mutable DWARFAbbreviationDeclarationSetMap::const_iterator PrevAbbrOffsetPos;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
index 2d82104ea098..dfbbb95076e8 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
@@ -46,8 +46,8 @@ public:
};
private:
- typedef std::vector<Descriptor> DescriptorColl;
- typedef iterator_range<DescriptorColl::const_iterator> desc_iterator_range;
+ using DescriptorColl = std::vector<Descriptor>;
+ using desc_iterator_range = iterator_range<DescriptorColl::const_iterator>;
uint32_t Offset;
Header HeaderData;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
index 2237aa361d18..ea71a50f3270 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -76,8 +76,8 @@ private:
}
};
- typedef std::vector<Range> RangeColl;
- typedef RangeColl::const_iterator RangeCollIterator;
+ using RangeColl = std::vector<Range>;
+ using RangeCollIterator = RangeColl::const_iterator;
std::vector<RangeEndpoint> Endpoints;
RangeColl Aranges;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
index 39a7ef71de97..4d624812f186 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
@@ -10,7 +10,9 @@
#ifndef LLVM_DEBUGINFO_DWARFDEBUGLINE_H
#define LLVM_DEBUGINFO_DWARFDEBUGLINE_H
+#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DIContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/DataExtractor.h"
#include <cstdint>
@@ -42,10 +44,10 @@ public:
/// The size in bytes of the statement information for this compilation unit
/// (not including the total_length field itself).
uint64_t TotalLength;
- /// Version identifier for the statement information format.
- uint16_t Version;
- /// In v5, size in bytes of an address (or segment offset).
- uint8_t AddressSize;
+ /// Version, address size (starting in v5), and DWARF32/64 format; these
+ /// parameters affect interpretation of forms (used in the directory and
+ /// file tables starting with v5).
+ DWARFFormParams FormParams;
/// In v5, size in bytes of a segment selector.
uint8_t SegSelectorSize;
/// The number of bytes following the prologue_length field to the beginning
@@ -70,15 +72,18 @@ public:
std::vector<StringRef> IncludeDirectories;
std::vector<FileNameEntry> FileNames;
- bool IsDWARF64;
+ const DWARFFormParams getFormParams() const { return FormParams; }
+ uint16_t getVersion() const { return FormParams.Version; }
+ uint8_t getAddressSize() const { return FormParams.AddrSize; }
+ bool isDWARF64() const { return FormParams.Format == dwarf::DWARF64; }
- uint32_t sizeofTotalLength() const { return IsDWARF64 ? 12 : 4; }
+ uint32_t sizeofTotalLength() const { return isDWARF64() ? 12 : 4; }
- uint32_t sizeofPrologueLength() const { return IsDWARF64 ? 8 : 4; }
+ uint32_t sizeofPrologueLength() const { return isDWARF64() ? 8 : 4; }
/// Length of the prologue in bytes.
uint32_t getLength() const {
- return PrologueLength + sizeofTotalLength() + sizeof(Version) +
+ return PrologueLength + sizeofTotalLength() + sizeof(getVersion()) +
sizeofPrologueLength();
}
@@ -104,7 +109,9 @@ public:
void postAppend();
void reset(bool DefaultIsStmt);
void dump(raw_ostream &OS) const;
+
static void dumpTableHeader(raw_ostream &OS);
+
static bool orderByAddress(const Row &LHS, const Row &RHS) {
return LHS.Address < RHS.Address;
}
@@ -216,11 +223,12 @@ public:
bool parse(DataExtractor DebugLineData, const RelocAddrMap *RMap,
uint32_t *OffsetPtr);
+ using RowVector = std::vector<Row>;
+ using RowIter = RowVector::const_iterator;
+ using SequenceVector = std::vector<Sequence>;
+ using SequenceIter = SequenceVector::const_iterator;
+
struct Prologue Prologue;
- typedef std::vector<Row> RowVector;
- typedef RowVector::const_iterator RowIter;
- typedef std::vector<Sequence> SequenceVector;
- typedef SequenceVector::const_iterator SequenceIter;
RowVector Rows;
SequenceVector Sequences;
@@ -244,14 +252,14 @@ private:
struct LineTable *LineTable;
/// The row number that starts at zero for the prologue, and increases for
/// each row added to the matrix.
- unsigned RowNumber;
+ unsigned RowNumber = 0;
struct Row Row;
struct Sequence Sequence;
};
- typedef std::map<uint32_t, LineTable> LineTableMapTy;
- typedef LineTableMapTy::iterator LineTableIter;
- typedef LineTableMapTy::const_iterator LineTableConstIter;
+ using LineTableMapTy = std::map<uint32_t, LineTable>;
+ using LineTableIter = LineTableMapTy::iterator;
+ using LineTableConstIter = LineTableMapTy::const_iterator;
const RelocAddrMap *RelocMap;
LineTableMapTy LineTableMap;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
index 6d4cd8d1b5a3..821da8f9b536 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
@@ -39,7 +39,7 @@ class DWARFDebugLoc {
SmallVector<Entry, 2> Entries;
};
- typedef SmallVector<LocationList, 4> LocationLists;
+ using LocationLists = SmallVector<LocationList, 4>;
/// A list of all the variables in the debug_loc section, each one describing
/// the locations in which the variable is stored.
@@ -71,7 +71,7 @@ class DWARFDebugLocDWO {
SmallVector<Entry, 2> Entries;
};
- typedef SmallVector<LocationList, 4> LocationLists;
+ using LocationLists = SmallVector<LocationList, 4>;
LocationLists Locations;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h b/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
index 85d98b45afcd..135c50761e36 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugMacro.h
@@ -40,7 +40,7 @@ class DWARFDebugMacro {
};
};
- typedef SmallVector<Entry, 4> MacroList;
+ using MacroList = SmallVector<Entry, 4>;
/// A list of all the macro entries in the debug_macinfo section.
MacroList Macros;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
index 437060bc8fec..49beec92ecc6 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
@@ -12,10 +12,8 @@
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/DataExtractor.h"
-
#include <cassert>
#include <cstdint>
-#include <utility>
#include <vector>
namespace llvm {
@@ -29,7 +27,7 @@ struct DWARFAddressRange {
};
/// DWARFAddressRangesVector - represents a set of absolute address ranges.
-typedef std::vector<DWARFAddressRange> DWARFAddressRangesVector;
+using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
class DWARFDebugRangeList {
public:
diff --git a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
index d6a3b52f2fe1..78fa6639db08 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
@@ -22,6 +22,35 @@ namespace llvm {
class DWARFUnit;
class raw_ostream;
+/// A helper struct for DWARFFormValue methods, providing information that
+/// allows it to know the byte size of DW_FORM values that vary in size
+/// depending on the DWARF version, address byte size, or DWARF32/DWARF64.
+struct DWARFFormParams {
+ uint16_t Version;
+ uint8_t AddrSize;
+ dwarf::DwarfFormat Format;
+
+ /// The definition of the size of form DW_FORM_ref_addr depends on the
+ /// version. In DWARF v2 it's the size of an address; after that, it's the
+ /// size of a reference.
+ uint8_t getRefAddrByteSize() const {
+ if (Version == 2)
+ return AddrSize;
+ return getDwarfOffsetByteSize();
+ }
+
+ /// The size of a reference is determined by the DWARF 32/64-bit format.
+ uint8_t getDwarfOffsetByteSize() const {
+ switch (Format) {
+ case dwarf::DwarfFormat::DWARF32:
+ return 4;
+ case dwarf::DwarfFormat::DWARF64:
+ return 8;
+ }
+ llvm_unreachable("Invalid Format value");
+ }
+};
+
class DWARFFormValue {
public:
enum FormClass {
@@ -104,79 +133,43 @@ public:
/// Get the fixed byte size for a given form.
///
- /// If the form always has a fixed valid byte size that doesn't depend on a
- /// DWARFUnit, then an Optional with a value will be returned. If the form
- /// can vary in size depending on the DWARFUnit (DWARF version, address byte
- /// size, or DWARF 32/64) and the DWARFUnit is valid, then an Optional with a
- /// valid value is returned. If the form is always encoded using a variable
- /// length storage format (ULEB or SLEB numbers or blocks) or the size
- /// depends on a DWARFUnit and the DWARFUnit is NULL, then None will be
- /// returned.
- /// \param Form The DWARF form to get the fixed byte size for
- /// \param U The DWARFUnit that can be used to help determine the byte size.
- ///
- /// \returns Optional<uint8_t> value with the fixed byte size or None if
- /// \p Form doesn't have a fixed byte size or a DWARFUnit wasn't supplied
- /// and was needed to calculate the byte size.
- static Optional<uint8_t> getFixedByteSize(dwarf::Form Form,
- const DWARFUnit *U = nullptr);
-
- /// Get the fixed byte size for a given form.
- ///
- /// If the form has a fixed byte size given a valid DWARF version and address
- /// byte size, then an Optional with a valid value is returned. If the form
- /// is always encoded using a variable length storage format (ULEB or SLEB
- /// numbers or blocks) then None will be returned.
+ /// If the form has a fixed byte size, then an Optional with a value will be
+ /// returned. If the form is always encoded using a variable length storage
+ /// format (ULEB or SLEB numbers or blocks) then None will be returned.
///
- /// \param Form DWARF form to get the fixed byte size for
- /// \param Version DWARF version number.
- /// \param AddrSize size of an address in bytes.
- /// \param Format enum value from llvm::dwarf::DwarfFormat.
+ /// \param Form DWARF form to get the fixed byte size for.
+ /// \param FormParams DWARF parameters to help interpret forms.
/// \returns Optional<uint8_t> value with the fixed byte size or None if
/// \p Form doesn't have a fixed byte size.
- static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, uint16_t Version,
- uint8_t AddrSize,
- llvm::dwarf::DwarfFormat Format);
+ static Optional<uint8_t> getFixedByteSize(dwarf::Form Form,
+ const DWARFFormParams FormParams);
- /// Skip a form in \p DebugInfoData at offset specified by \p OffsetPtr.
+ /// Skip a form's value in \p DebugInfoData at the offset specified by
+ /// \p OffsetPtr.
///
- /// Skips the bytes for this form in the debug info and updates the offset.
+ /// Skips the bytes for the current form and updates the offset.
///
- /// \param DebugInfoData the .debug_info data to use to skip the value.
- /// \param OffsetPtr a reference to the offset that will be updated.
- /// \param U the DWARFUnit to use when skipping the form in case the form
- /// size differs according to data in the DWARFUnit.
+ /// \param DebugInfoData The data where we want to skip the value.
+ /// \param OffsetPtr A reference to the offset that will be updated.
+ /// \param Params DWARF parameters to help interpret forms.
/// \returns true on success, false if the form was not skipped.
bool skipValue(DataExtractor DebugInfoData, uint32_t *OffsetPtr,
- const DWARFUnit *U) const;
-
- /// Skip a form in \p DebugInfoData at offset specified by \p OffsetPtr.
- ///
- /// Skips the bytes for this form in the debug info and updates the offset.
- ///
- /// \param Form the DW_FORM enumeration that indicates the form to skip.
- /// \param DebugInfoData the .debug_info data to use to skip the value.
- /// \param OffsetPtr a reference to the offset that will be updated.
- /// \param U the DWARFUnit to use when skipping the form in case the form
- /// size differs according to data in the DWARFUnit.
- /// \returns true on success, false if the form was not skipped.
- static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr, const DWARFUnit *U);
+ const DWARFFormParams Params) const {
+ return DWARFFormValue::skipValue(Form, DebugInfoData, OffsetPtr, Params);
+ }
- /// Skip a form in \p DebugInfoData at offset specified by \p OffsetPtr.
+ /// Skip a form's value in \p DebugInfoData at the offset specified by
+ /// \p OffsetPtr.
///
- /// Skips the bytes for this form in the debug info and updates the offset.
+ /// Skips the bytes for the specified form and updates the offset.
///
- /// \param Form the DW_FORM enumeration that indicates the form to skip.
- /// \param DebugInfoData the .debug_info data to use to skip the value.
- /// \param OffsetPtr a reference to the offset that will be updated.
- /// \param Version DWARF version number.
- /// \param AddrSize size of an address in bytes.
- /// \param Format enum value from llvm::dwarf::DwarfFormat.
+ /// \param Form The DW_FORM enumeration that indicates the form to skip.
+ /// \param DebugInfoData The data where we want to skip the value.
+ /// \param OffsetPtr A reference to the offset that will be updated.
+ /// \param FormParams DWARF parameters to help interpret forms.
/// \returns true on success, false if the form was not skipped.
static bool skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
- uint32_t *OffsetPtr, uint16_t Version, uint8_t AddrSize,
- llvm::dwarf::DwarfFormat Format);
+ uint32_t *OffsetPtr, const DWARFFormParams FormParams);
private:
void dumpString(raw_ostream &OS) const;
diff --git a/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h b/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
index f143de334737..f51838424614 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFRelocMap.h
@@ -12,7 +12,6 @@
#include "llvm/ADT/DenseMap.h"
#include <cstdint>
-#include <utility>
namespace llvm {
@@ -28,7 +27,7 @@ struct RelocAddrEntry {
/// dwarf where we expect relocated values. This adds a bit of complexity to the
/// dwarf parsing/extraction at the benefit of not allocating memory for the
/// entire size of the debug info sections.
-typedef DenseMap<uint64_t, RelocAddrEntry> RelocAddrMap;
+using RelocAddrMap = DenseMap<uint64_t, RelocAddrEntry>;
} // end namespace llvm
diff --git a/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 945b8999ff22..d7ccaf82bc9a 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -19,11 +19,10 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
-#include "llvm/Object/Binary.h"
-#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/DataExtractor.h"
#include <algorithm>
#include <cassert>
@@ -31,6 +30,7 @@
#include <cstdint>
#include <map>
#include <memory>
+#include <utility>
#include <vector>
namespace llvm {
@@ -72,9 +72,9 @@ class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
bool Parsed = false;
public:
- typedef SmallVectorImpl<std::unique_ptr<UnitType>> UnitVector;
- typedef typename UnitVector::iterator iterator;
- typedef llvm::iterator_range<typename UnitVector::iterator> iterator_range;
+ using UnitVector = SmallVectorImpl<std::unique_ptr<UnitType>>;
+ using iterator = typename UnitVector::iterator;
+ using iterator_range = llvm::iterator_range<typename UnitVector::iterator>;
UnitType *getUnitForOffset(uint32_t Offset) const override {
auto *CU = std::upper_bound(
@@ -128,12 +128,13 @@ class DWARFUnit {
bool isDWO;
const DWARFUnitSectionBase &UnitSection;
+ // Version, address size, and DWARF format.
+ DWARFFormParams FormParams;
+
uint32_t Offset;
uint32_t Length;
const DWARFAbbreviationDeclarationSet *Abbrevs;
- uint16_t Version;
uint8_t UnitType;
- uint8_t AddrSize;
uint64_t BaseAddr;
/// The compile unit debug information entry items.
std::vector<DWARFDebugInfoEntry> DieArray;
@@ -142,8 +143,9 @@ class DWARFUnit {
/// IntervalMap does not support range removal, as a result, we use the
/// std::map::upper_bound for address range lookup.
std::map<uint64_t, std::pair<uint64_t, DWARFDie>> AddrDieMap;
- typedef iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>
- die_iterator_range;
+
+ using die_iterator_range =
+ iterator_range<std::vector<DWARFDebugInfoEntry>::iterator>;
std::shared_ptr<DWARFUnit> DWO;
@@ -159,7 +161,7 @@ protected:
virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr);
/// Size in bytes of the unit header.
- virtual uint32_t getHeaderSize() const { return Version <= 4 ? 11 : 12; }
+ virtual uint32_t getHeaderSize() const { return getVersion() <= 4 ? 11 : 12; }
public:
DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
@@ -197,7 +199,8 @@ public:
uint64_t getStringOffsetSectionRelocation(uint32_t Index) const;
DataExtractor getDebugInfoExtractor() const {
- return DataExtractor(InfoSection.Data, isLittleEndian, AddrSize);
+ return DataExtractor(InfoSection.Data, isLittleEndian,
+ getAddressByteSize());
}
DataExtractor getStringExtractor() const {
@@ -220,10 +223,14 @@ public:
uint32_t getOffset() const { return Offset; }
uint32_t getNextUnitOffset() const { return Offset + Length + 4; }
uint32_t getLength() const { return Length; }
- uint16_t getVersion() const { return Version; }
- dwarf::DwarfFormat getFormat() const {
- return dwarf::DwarfFormat::DWARF32; // FIXME: Support DWARF64.
+ const DWARFFormParams &getFormParams() const { return FormParams; }
+ uint16_t getVersion() const { return FormParams.Version; }
+ dwarf::DwarfFormat getFormat() const { return FormParams.Format; }
+ uint8_t getAddressByteSize() const { return FormParams.AddrSize; }
+ uint8_t getRefAddrByteSize() const { return FormParams.getRefAddrByteSize(); }
+ uint8_t getDwarfOffsetByteSize() const {
+ return FormParams.getDwarfOffsetByteSize();
}
const DWARFAbbreviationDeclarationSet *getAbbreviations() const {
@@ -231,19 +238,6 @@ public:
}
uint8_t getUnitType() const { return UnitType; }
- uint8_t getAddressByteSize() const { return AddrSize; }
-
- uint8_t getRefAddrByteSize() const {
- if (Version == 2)
- return AddrSize;
- return getDwarfOffsetByteSize();
- }
-
- uint8_t getDwarfOffsetByteSize() const {
- if (getFormat() == dwarf::DwarfFormat::DWARF64)
- return 8;
- return 4;
- }
uint64_t getBaseAddress() const { return BaseAddr; }
diff --git a/include/llvm/DebugInfo/MSF/MSFBuilder.h b/include/llvm/DebugInfo/MSF/MSFBuilder.h
index 6d067cc1c238..b2c8f2d1c20d 100644
--- a/include/llvm/DebugInfo/MSF/MSFBuilder.h
+++ b/include/llvm/DebugInfo/MSF/MSFBuilder.h
@@ -12,18 +12,16 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
-
#include "llvm/DebugInfo/MSF/MSFCommon.h"
-
#include "llvm/Support/Allocator.h"
-#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
-
+#include <cstdint>
#include <utility>
#include <vector>
namespace llvm {
namespace msf {
+
class MSFBuilder {
public:
/// \brief Create a new `MSFBuilder`.
@@ -122,7 +120,7 @@ private:
Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks);
uint32_t computeDirectoryByteSize() const;
- typedef std::vector<uint32_t> BlockList;
+ using BlockList = std::vector<uint32_t>;
BumpPtrAllocator &Allocator;
@@ -136,7 +134,8 @@ private:
std::vector<uint32_t> DirectoryBlocks;
std::vector<std::pair<uint32_t, BlockList>> StreamData;
};
-} // namespace msf
-} // namespace llvm
+
+} // end namespace msf
+} // end namespace llvm
#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H
diff --git a/include/llvm/DebugInfo/MSF/MSFCommon.h b/include/llvm/DebugInfo/MSF/MSFCommon.h
index 93a9c808b736..eca1b8b89ebd 100644
--- a/include/llvm/DebugInfo/MSF/MSFCommon.h
+++ b/include/llvm/DebugInfo/MSF/MSFCommon.h
@@ -12,15 +12,15 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
-
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MathExtras.h"
-
+#include <cstdint>
#include <vector>
namespace llvm {
namespace msf {
+
static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
't', ' ', 'C', '/', 'C', '+', '+', ' ',
'M', 'S', 'F', ' ', '7', '.', '0', '0',
@@ -50,8 +50,9 @@ struct SuperBlock {
};
struct MSFLayout {
- MSFLayout() : SB(nullptr) {}
- const SuperBlock *SB;
+ MSFLayout() = default;
+
+ const SuperBlock *SB = nullptr;
BitVector FreePageMap;
ArrayRef<support::ulittle32_t> DirectoryBlocks;
ArrayRef<support::ulittle32_t> StreamSizes;
@@ -90,15 +91,16 @@ inline uint32_t getFpmIntervalLength(const MSFLayout &L) {
inline uint32_t getNumFpmIntervals(const MSFLayout &L) {
uint32_t Length = getFpmIntervalLength(L);
- return llvm::alignTo(L.SB->NumBlocks, Length) / Length;
+ return alignTo(L.SB->NumBlocks, Length) / Length;
}
inline uint32_t getFullFpmByteSize(const MSFLayout &L) {
- return llvm::alignTo(L.SB->NumBlocks, 8) / 8;
+ return alignTo(L.SB->NumBlocks, 8) / 8;
}
Error validateSuperBlock(const SuperBlock &SB);
-} // namespace msf
-} // namespace llvm
+
+} // end namespace msf
+} // end namespace llvm
#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H
diff --git a/include/llvm/DebugInfo/MSF/MappedBlockStream.h b/include/llvm/DebugInfo/MSF/MappedBlockStream.h
index 02f3cb09b004..6d88d2be85c9 100644
--- a/include/llvm/DebugInfo/MSF/MappedBlockStream.h
+++ b/include/llvm/DebugInfo/MSF/MappedBlockStream.h
@@ -1,5 +1,4 @@
-//===- MappedBlockStream.h - Discontiguous stream data in an MSF -*- C++
-//-*-===//
+//==- MappedBlockStream.h - Discontiguous stream data in an MSF --*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
@@ -13,7 +12,6 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStream.h"
@@ -21,6 +19,7 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
#include <cstdint>
+#include <memory>
#include <vector>
namespace llvm {
@@ -40,6 +39,7 @@ struct MSFLayout;
/// of bytes.
class MappedBlockStream : public BinaryStream {
friend class WritableMappedBlockStream;
+
public:
static std::unique_ptr<MappedBlockStream>
createStream(uint32_t BlockSize, const MSFStreamLayout &Layout,
@@ -57,8 +57,8 @@ public:
createDirectoryStream(const MSFLayout &Layout, BinaryStreamRef MsfData,
BumpPtrAllocator &Allocator);
- llvm::support::endianness getEndian() const override {
- return llvm::support::little;
+ support::endianness getEndian() const override {
+ return support::little;
}
Error readBytes(uint32_t Offset, uint32_t Size,
@@ -68,7 +68,7 @@ public:
uint32_t getLength() override;
- llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
+ BumpPtrAllocator &getAllocator() { return Allocator; }
void invalidateCache();
@@ -92,7 +92,7 @@ private:
const MSFStreamLayout StreamLayout;
BinaryStreamRef MsfData;
- typedef MutableArrayRef<uint8_t> CacheEntry;
+ using CacheEntry = MutableArrayRef<uint8_t>;
// We just store the allocator by reference. We use this to allocate
// contiguous memory for things like arrays or strings that cross a block
@@ -124,8 +124,8 @@ public:
createFpmStream(const MSFLayout &Layout, WritableBinaryStreamRef MsfData,
BumpPtrAllocator &Allocator);
- llvm::support::endianness getEndian() const override {
- return llvm::support::little;
+ support::endianness getEndian() const override {
+ return support::little;
}
Error readBytes(uint32_t Offset, uint32_t Size,
@@ -141,6 +141,7 @@ public:
const MSFStreamLayout &getStreamLayout() const {
return ReadInterface.getStreamLayout();
}
+
uint32_t getBlockSize() const { return ReadInterface.getBlockSize(); }
uint32_t getNumBlocks() const { return ReadInterface.getNumBlocks(); }
uint32_t getStreamLength() const { return ReadInterface.getStreamLength(); }
@@ -153,7 +154,6 @@ protected:
private:
MappedBlockStream ReadInterface;
-
WritableBinaryStreamRef WriteInterface;
};
diff --git a/include/llvm/DebugInfo/PDB/DIA/DIASession.h b/include/llvm/DebugInfo/PDB/DIA/DIASession.h
index 3f5818631e7b..350442556bef 100644
--- a/include/llvm/DebugInfo/PDB/DIA/DIASession.h
+++ b/include/llvm/DebugInfo/PDB/DIA/DIASession.h
@@ -31,7 +31,7 @@ public:
uint64_t getLoadAddress() const override;
void setLoadAddress(uint64_t Address) override;
- std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+ std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
std::unique_ptr<PDBSymbol>
diff --git a/include/llvm/DebugInfo/PDB/IPDBSession.h b/include/llvm/DebugInfo/PDB/IPDBSession.h
index 85d9fe124859..cf195095c8d2 100644
--- a/include/llvm/DebugInfo/PDB/IPDBSession.h
+++ b/include/llvm/DebugInfo/PDB/IPDBSession.h
@@ -29,7 +29,7 @@ public:
virtual uint64_t getLoadAddress() const = 0;
virtual void setLoadAddress(uint64_t Address) = 0;
- virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() const = 0;
+ virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;
virtual std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const = 0;
template <typename T>
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
index a89e26ae943c..e4cb1b24e30d 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h
@@ -14,6 +14,7 @@
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
+#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/Support/Error.h"
@@ -52,6 +53,9 @@ public:
void
addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);
+ void
+ addDebugSubsection(const codeview::DebugSubsectionRecord &SubsectionContents);
+
uint16_t getStreamIndex() const;
StringRef getModuleName() const { return ModuleName; }
StringRef getObjFileName() const { return ObjFileName; }
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStream.h b/include/llvm/DebugInfo/PDB/Native/DbiStream.h
index 7123e88cd642..3bf790726656 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiStream.h
@@ -63,6 +63,13 @@ public:
PDB_Machine getMachineType() const;
+ BinarySubstreamRef getSectionContributionData() const;
+ BinarySubstreamRef getSecMapSubstreamData() const;
+ BinarySubstreamRef getModiSubstreamData() const;
+ BinarySubstreamRef getFileInfoSubstreamData() const;
+ BinarySubstreamRef getTypeServerMapSubstreamData() const;
+ BinarySubstreamRef getECSubstreamData() const;
+
/// If the given stream type is present, returns its stream index. If it is
/// not present, returns InvalidStreamIndex.
uint32_t getDebugStreamIndex(DbgHeaderType Type) const;
@@ -87,10 +94,12 @@ private:
PDBStringTable ECNames;
- BinaryStreamRef SecContrSubstream;
- BinaryStreamRef SecMapSubstream;
- BinaryStreamRef TypeServerMapSubstream;
- BinaryStreamRef ECSubstream;
+ BinarySubstreamRef SecContrSubstream;
+ BinarySubstreamRef SecMapSubstream;
+ BinarySubstreamRef ModiSubstream;
+ BinarySubstreamRef FileInfoSubstream;
+ BinarySubstreamRef TypeServerMapSubstream;
+ BinarySubstreamRef ECSubstream;
DbiModuleList Modules;
diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
index aeb2e2ab026a..744411854181 100644
--- a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
+++ b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
@@ -58,6 +58,7 @@ public:
Expected<DbiModuleDescriptorBuilder &> addModuleInfo(StringRef ModuleName);
Error addModuleSourceFile(StringRef Module, StringRef File);
+ Error addModuleSourceFile(DbiModuleDescriptorBuilder &Module, StringRef File);
Expected<uint32_t> getSourceFileNameIndex(StringRef FileName);
Error finalizeMsfLayout();
diff --git a/include/llvm/DebugInfo/PDB/Native/InfoStream.h b/include/llvm/DebugInfo/PDB/Native/InfoStream.h
index fc91fc7097bd..37bf5f3b573c 100644
--- a/include/llvm/DebugInfo/PDB/Native/InfoStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/InfoStream.h
@@ -47,6 +47,8 @@ public:
const NamedStreamMap &getNamedStreams() const;
+ BinarySubstreamRef getNamedStreamsBuffer() const;
+
uint32_t getNamedStreamIndex(llvm::StringRef Name) const;
iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
@@ -71,6 +73,8 @@ private:
// universally unique.
PDB_UniqueId Guid;
+ BinarySubstreamRef SubNamedStreams;
+
std::vector<PdbRaw_FeatureSig> FeatureSignatures;
PdbRaw_Features Features = PdbFeatureNone;
diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
index c744696ae250..5565cd5582bc 100644
--- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h
@@ -41,9 +41,12 @@ public:
iterator_range<codeview::CVSymbolArray::Iterator>
symbols(bool *HadError) const;
- const codeview::CVSymbolArray &getSymbolArray() const {
- return SymbolsSubstream;
- }
+ const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
+
+ BinarySubstreamRef getSymbolsSubstream() const;
+ BinarySubstreamRef getC11LinesSubstream() const;
+ BinarySubstreamRef getC13LinesSubstream() const;
+ BinarySubstreamRef getGlobalRefsSubstream() const;
ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default;
@@ -63,10 +66,12 @@ private:
std::shared_ptr<msf::MappedBlockStream> Stream;
- codeview::CVSymbolArray SymbolsSubstream;
- BinaryStreamRef C11LinesSubstream;
- BinaryStreamRef C13LinesSubstream;
- BinaryStreamRef GlobalRefsSubstream;
+ codeview::CVSymbolArray SymbolArray;
+
+ BinarySubstreamRef SymbolsSubstream;
+ BinarySubstreamRef C11LinesSubstream;
+ BinarySubstreamRef C13LinesSubstream;
+ BinarySubstreamRef GlobalRefsSubstream;
codeview::DebugSubsectionArray Subsections;
};
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
index 22ed61910d94..1687737f0e7f 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
@@ -18,7 +18,11 @@ namespace pdb {
class NativeCompilandSymbol : public NativeRawSymbol {
public:
- NativeCompilandSymbol(NativeSession &Session, DbiModuleDescriptor MI);
+ NativeCompilandSymbol(NativeSession &Session, uint32_t SymbolId,
+ DbiModuleDescriptor MI);
+
+ std::unique_ptr<NativeRawSymbol> clone() const override;
+
PDB_SymType getSymTag() const override;
bool isEditAndContinueEnabled() const override;
uint32_t getLexicalParentId() const override;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
index 9516810539b6..15bac78df191 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeExeSymbol.h
@@ -18,7 +18,9 @@ namespace pdb {
class NativeExeSymbol : public NativeRawSymbol {
public:
- NativeExeSymbol(NativeSession &Session);
+ NativeExeSymbol(NativeSession &Session, uint32_t SymbolId);
+
+ std::unique_ptr<NativeRawSymbol> clone() const override;
std::unique_ptr<IPDBEnumSymbols>
findChildren(PDB_SymType Type) const override;
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
index e1e78035ff38..5e4aaafff1a9 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeRawSymbol.h
@@ -19,7 +19,9 @@ class NativeSession;
class NativeRawSymbol : public IPDBRawSymbol {
public:
- explicit NativeRawSymbol(NativeSession &PDBSession);
+ NativeRawSymbol(NativeSession &PDBSession, uint32_t SymbolId);
+
+ virtual std::unique_ptr<NativeRawSymbol> clone() const = 0;
void dump(raw_ostream &OS, int Indent) const override;
@@ -201,6 +203,7 @@ public:
protected:
NativeSession &Session;
+ uint32_t SymbolId;
};
}
diff --git a/include/llvm/DebugInfo/PDB/Native/NativeSession.h b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
index e6da266f796d..bbe207738e02 100644
--- a/include/llvm/DebugInfo/PDB/Native/NativeSession.h
+++ b/include/llvm/DebugInfo/PDB/Native/NativeSession.h
@@ -32,7 +32,7 @@ public:
uint64_t getLoadAddress() const override;
void setLoadAddress(uint64_t Address) override;
- std::unique_ptr<PDBSymbolExe> getGlobalScope() const override;
+ std::unique_ptr<PDBSymbolExe> getGlobalScope() override;
std::unique_ptr<PDBSymbol> getSymbolById(uint32_t SymbolId) const override;
std::unique_ptr<PDBSymbol>
diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFile.h b/include/llvm/DebugInfo/PDB/Native/PDBFile.h
index 4d3c569c3cdf..4f6ad115e7df 100644
--- a/include/llvm/DebugInfo/PDB/Native/PDBFile.h
+++ b/include/llvm/DebugInfo/PDB/Native/PDBFile.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/MSF/IMSFFile.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
+#include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/Endian.h"
@@ -85,6 +86,8 @@ public:
ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
+ msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
+
Error parseFileHeaders();
Error parseStreamData();
diff --git a/include/llvm/DebugInfo/PDB/Native/TpiStream.h b/include/llvm/DebugInfo/PDB/Native/TpiStream.h
index 0ee697696ca5..d3475205a6c2 100644
--- a/include/llvm/DebugInfo/PDB/Native/TpiStream.h
+++ b/include/llvm/DebugInfo/PDB/Native/TpiStream.h
@@ -16,6 +16,7 @@
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
#include "llvm/Support/BinaryStreamArray.h"
+#include "llvm/Support/BinaryStreamRef.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Error.h"
@@ -57,6 +58,8 @@ public:
codeview::LazyRandomTypeCollection &typeCollection() { return *Types; }
+ BinarySubstreamRef getTypeRecordsSubstream() const;
+
Error commit();
private:
@@ -65,6 +68,8 @@ private:
std::unique_ptr<codeview::LazyRandomTypeCollection> Types;
+ BinarySubstreamRef TypeRecordsSubstream;
+
codeview::CVTypeArray TypeRecords;
std::unique_ptr<BinaryStream> HashStream;
diff --git a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
index e0bec6f6cf85..e576a91e887c 100644
--- a/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
+++ b/include/llvm/DebugInfo/Symbolize/SymbolizableModule.h
@@ -1,4 +1,4 @@
-//===-- SymbolizableModule.h ------------------------------------ C++ -----===//
+//===- SymbolizableModule.h -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,12 +14,7 @@
#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H
#include "llvm/DebugInfo/DIContext.h"
-
-namespace llvm {
-namespace object {
-class ObjectFile;
-}
-}
+#include <cstdint>
namespace llvm {
namespace symbolize {
@@ -28,7 +23,8 @@ using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
class SymbolizableModule {
public:
- virtual ~SymbolizableModule() {}
+ virtual ~SymbolizableModule() = default;
+
virtual DILineInfo symbolizeCode(uint64_t ModuleOffset,
FunctionNameKind FNKind,
bool UseSymbolTable) const = 0;
@@ -45,7 +41,7 @@ public:
virtual uint64_t getModulePreferredBase() const = 0;
};
-} // namespace symbolize
-} // namespace llvm
+} // end namespace symbolize
+} // end namespace llvm
#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZABLEMODULE_H
diff --git a/include/llvm/DebugInfo/Symbolize/Symbolize.h b/include/llvm/DebugInfo/Symbolize/Symbolize.h
index 5103cc03a6bd..d98d49b24bca 100644
--- a/include/llvm/DebugInfo/Symbolize/Symbolize.h
+++ b/include/llvm/DebugInfo/Symbolize/Symbolize.h
@@ -1,4 +1,4 @@
-//===-- Symbolize.h --------------------------------------------- C++ -----===//
+//===- Symbolize.h ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -10,21 +10,27 @@
// Header for LLVM symbolization library.
//
//===----------------------------------------------------------------------===//
+
#ifndef LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H
#define LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H
#include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
+#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
-#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/Error.h"
+#include <algorithm>
+#include <cstdint>
#include <map>
#include <memory>
#include <string>
#include <utility>
+#include <vector>
namespace llvm {
namespace symbolize {
using namespace object;
+
using FunctionNameKind = DILineInfoSpecifier::FunctionNameKind;
class LLVMSymbolizer {
@@ -36,6 +42,7 @@ public:
bool RelativeAddresses : 1;
std::string DefaultArch;
std::vector<std::string> DsymHints;
+
Options(FunctionNameKind PrintFunctions = FunctionNameKind::LinkageName,
bool UseSymbolTable = true, bool Demangle = true,
bool RelativeAddresses = false, std::string DefaultArch = "")
@@ -45,6 +52,7 @@ public:
};
LLVMSymbolizer(const Options &Opts = Options()) : Opts(Opts) {}
+
~LLVMSymbolizer() {
flush();
}
@@ -56,6 +64,7 @@ public:
Expected<DIGlobal> symbolizeData(const std::string &ModuleName,
uint64_t ModuleOffset);
void flush();
+
static std::string
DemangleName(const std::string &Name,
const SymbolizableModule *DbiModuleDescriptor);
@@ -63,7 +72,7 @@ public:
private:
// Bundles together object file with code/data and object file with
// corresponding debug info. These objects can be the same.
- typedef std::pair<ObjectFile*, ObjectFile*> ObjectPair;
+ using ObjectPair = std::pair<ObjectFile *, ObjectFile *>;
/// Returns a SymbolizableModule or an error if loading debug info failed.
/// Only one attempt is made to load a module, and errors during loading are
@@ -106,7 +115,7 @@ private:
Options Opts;
};
-} // namespace symbolize
-} // namespace llvm
+} // end namespace symbolize
+} // end namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_SYMBOLIZE_SYMBOLIZE_H
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 1586f7b80669..2830a2628753 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -15,54 +15,58 @@
#ifndef LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
#define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
-#include "RuntimeDyld.h"
#include "llvm-c/ExecutionEngine.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/ValueHandle.h"
-#include "llvm/IR/ValueMap.h"
#include "llvm/Object/Binary.h"
+#include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/CodeGen.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
+#include <algorithm>
+#include <cstdint>
#include <functional>
#include <map>
+#include <memory>
#include <string>
#include <vector>
namespace llvm {
-struct GenericValue;
class Constant;
-class DataLayout;
-class ExecutionEngine;
class Function;
-class GlobalVariable;
+struct GenericValue;
class GlobalValue;
+class GlobalVariable;
class JITEventListener;
-class MachineCodeInfo;
class MCJITMemoryManager;
-class MutexGuard;
class ObjectCache;
class RTDyldMemoryManager;
class Triple;
class Type;
namespace object {
- class Archive;
- class ObjectFile;
-}
+
+class Archive;
+class ObjectFile;
+
+} // end namespace object
/// \brief Helper class for helping synchronize access to the global address map
/// table. Access to this class should be serialized under a mutex.
class ExecutionEngineState {
public:
- typedef StringMap<uint64_t> GlobalAddressMapTy;
+ using GlobalAddressMapTy = StringMap<uint64_t>;
private:
-
/// GlobalAddressMap - A mapping between LLVM global symbol names values and
/// their actualized version...
GlobalAddressMapTy GlobalAddressMap;
@@ -74,7 +78,6 @@ private:
std::map<uint64_t, std::string> GlobalAddressReverseMap;
public:
-
GlobalAddressMapTy &getGlobalAddressMap() {
return GlobalAddressMap;
}
@@ -509,13 +512,15 @@ private:
};
namespace EngineKind {
+
// These are actually bitmasks that get or-ed together.
enum Kind {
JIT = 0x1,
Interpreter = 0x2
};
const static Kind Either = (Kind)(JIT | Interpreter);
-}
+
+} // end namespace EngineKind
/// Builder class for ExecutionEngines. Use this by stack-allocating a builder,
/// chaining the various set* methods, and terminating it with a .create()
@@ -655,6 +660,6 @@ public:
// Create wrappers for C Binding types (see CBindingWrapping.h).
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ExecutionEngine, LLVMExecutionEngineRef)
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H
diff --git a/include/llvm/ExecutionEngine/GenericValue.h b/include/llvm/ExecutionEngine/GenericValue.h
index 537745519ddb..504e30a018b6 100644
--- a/include/llvm/ExecutionEngine/GenericValue.h
+++ b/include/llvm/ExecutionEngine/GenericValue.h
@@ -1,4 +1,4 @@
-//===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
+//===- GenericValue.h - Represent any type of LLVM value --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,18 +11,15 @@
//
//===----------------------------------------------------------------------===//
-
#ifndef LLVM_EXECUTIONENGINE_GENERICVALUE_H
#define LLVM_EXECUTIONENGINE_GENERICVALUE_H
#include "llvm/ADT/APInt.h"
-#include "llvm/Support/DataTypes.h"
#include <vector>
namespace llvm {
-typedef void* PointerTy;
-class APInt;
+using PointerTy = void *;
struct GenericValue {
struct IntPair {
@@ -30,25 +27,29 @@ struct GenericValue {
unsigned int second;
};
union {
- double DoubleVal;
- float FloatVal;
- PointerTy PointerVal;
- struct IntPair UIntPairVal;
- unsigned char Untyped[8];
+ double DoubleVal;
+ float FloatVal;
+ PointerTy PointerVal;
+ struct IntPair UIntPairVal;
+ unsigned char Untyped[8];
};
- APInt IntVal; // also used for long doubles.
+ APInt IntVal; // also used for long doubles.
// For aggregate data types.
std::vector<GenericValue> AggregateVal;
// to make code faster, set GenericValue to zero could be omitted, but it is
// potentially can cause problems, since GenericValue to store garbage
// instead of zero.
- GenericValue() : IntVal(1,0) {UIntPairVal.first = 0; UIntPairVal.second = 0;}
- explicit GenericValue(void *V) : PointerVal(V), IntVal(1,0) { }
+ GenericValue() : IntVal(1, 0) {
+ UIntPairVal.first = 0;
+ UIntPairVal.second = 0;
+ }
+ explicit GenericValue(void *V) : PointerVal(V), IntVal(1, 0) {}
};
inline GenericValue PTOGV(void *P) { return GenericValue(P); }
-inline void* GVTOP(const GenericValue &GV) { return GV.PointerVal; }
+inline void *GVTOP(const GenericValue &GV) { return GV.PointerVal; }
+
+} // end namespace llvm
-} // End llvm namespace.
-#endif
+#endif // LLVM_EXECUTIONENGINE_GENERICVALUE_H
diff --git a/include/llvm/ExecutionEngine/JITEventListener.h b/include/llvm/ExecutionEngine/JITEventListener.h
index 94ec4e36a199..ff7840f00a44 100644
--- a/include/llvm/ExecutionEngine/JITEventListener.h
+++ b/include/llvm/ExecutionEngine/JITEventListener.h
@@ -15,8 +15,8 @@
#ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
#define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
-#include "RuntimeDyld.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/DebugLoc.h"
#include <cstdint>
#include <vector>
@@ -28,7 +28,9 @@ class MachineFunction;
class OProfileWrapper;
namespace object {
- class ObjectFile;
+
+class ObjectFile;
+
} // end namespace object
/// JITEvent_EmittedFunctionDetails - Helper struct for containing information
@@ -57,7 +59,7 @@ struct JITEvent_EmittedFunctionDetails {
/// The default implementation of each method does nothing.
class JITEventListener {
public:
- typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
+ using EmittedFunctionDetails = JITEvent_EmittedFunctionDetails;
public:
JITEventListener() = default;
diff --git a/include/llvm/ExecutionEngine/JITSymbol.h b/include/llvm/ExecutionEngine/JITSymbol.h
index 88929482ce76..f09e95fddb97 100644
--- a/include/llvm/ExecutionEngine/JITSymbol.h
+++ b/include/llvm/ExecutionEngine/JITSymbol.h
@@ -1,4 +1,4 @@
-//===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
+//===- JITSymbol.h - JIT symbol abstraction ---------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -26,16 +26,18 @@ namespace llvm {
class GlobalValue;
namespace object {
- class BasicSymbolRef;
+
+class BasicSymbolRef;
+
} // end namespace object
/// @brief Represents an address in the target process's address space.
-typedef uint64_t JITTargetAddress;
+using JITTargetAddress = uint64_t;
/// @brief Flags for symbols in the JIT.
class JITSymbolFlags {
public:
- typedef uint8_t UnderlyingType;
+ using UnderlyingType = uint8_t;
enum FlagNames : UnderlyingType {
None = 0,
@@ -46,7 +48,7 @@ public:
};
/// @brief Default-construct a JITSymbolFlags instance.
- JITSymbolFlags() : Flags(None) {}
+ JITSymbolFlags() = default;
/// @brief Construct a JITSymbolFlags instance from the given flags.
JITSymbolFlags(FlagNames Flags) : Flags(Flags) {}
@@ -81,15 +83,14 @@ public:
static JITSymbolFlags fromObjectSymbol(const object::BasicSymbolRef &Symbol);
private:
- UnderlyingType Flags;
+ UnderlyingType Flags = None;
};
/// @brief Represents a symbol that has been evaluated to an address already.
class JITEvaluatedSymbol {
public:
/// @brief Create a 'null' symbol.
- JITEvaluatedSymbol(std::nullptr_t)
- : Address(0) {}
+ JITEvaluatedSymbol(std::nullptr_t) {}
/// @brief Create a symbol for the given address and flags.
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
@@ -105,19 +106,18 @@ public:
JITSymbolFlags getFlags() const { return Flags; }
private:
- JITTargetAddress Address;
+ JITTargetAddress Address = 0;
JITSymbolFlags Flags;
};
/// @brief Represents a symbol in the JIT.
class JITSymbol {
public:
- typedef std::function<JITTargetAddress()> GetAddressFtor;
+ using GetAddressFtor = std::function<JITTargetAddress()>;
/// @brief Create a 'null' symbol that represents failure to find a symbol
/// definition.
- JITSymbol(std::nullptr_t)
- : CachedAddr(0) {}
+ JITSymbol(std::nullptr_t) {}
/// @brief Create a symbol for a definition with a known address.
JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
@@ -137,7 +137,7 @@ public:
/// user can materialize the definition at any time by calling the getAddress
/// method.
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
- : GetAddress(std::move(GetAddress)), CachedAddr(0), Flags(Flags) {}
+ : GetAddress(std::move(GetAddress)), Flags(Flags) {}
/// @brief Returns true if the symbol exists, false otherwise.
explicit operator bool() const { return CachedAddr || GetAddress; }
@@ -157,7 +157,7 @@ public:
private:
GetAddressFtor GetAddress;
- JITTargetAddress CachedAddr;
+ JITTargetAddress CachedAddr = 0;
JITSymbolFlags Flags;
};
diff --git a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
index 2fccf8a0f625..8ac1b6bca0a7 100644
--- a/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
@@ -24,16 +24,20 @@
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/Attributes.h"
+#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/Instruction.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/ValueMapper.h"
#include <algorithm>
#include <cassert>
#include <functional>
@@ -46,6 +50,9 @@
#include <vector>
namespace llvm {
+
+class Value;
+
namespace orc {
/// @brief Compile-on-demand layer.
@@ -77,15 +84,15 @@ private:
return LambdaMaterializer<MaterializerFtor>(std::move(M));
}
- typedef typename BaseLayerT::ModuleSetHandleT BaseLayerModuleSetHandleT;
+ using BaseLayerModuleHandleT = typename BaseLayerT::ModuleHandleT;
// Provide type-erasure for the Modules and MemoryManagers.
template <typename ResourceT>
class ResourceOwner {
public:
ResourceOwner() = default;
- ResourceOwner(const ResourceOwner&) = delete;
- ResourceOwner& operator=(const ResourceOwner&) = delete;
+ ResourceOwner(const ResourceOwner &) = delete;
+ ResourceOwner &operator=(const ResourceOwner &) = delete;
virtual ~ResourceOwner() = default;
virtual ResourceT& getResource() const = 0;
@@ -106,7 +113,7 @@ private:
template <typename ResourceT, typename ResourcePtrT>
std::unique_ptr<ResourceOwner<ResourceT>>
wrapOwnership(ResourcePtrT ResourcePtr) {
- typedef ResourceOwnerImpl<ResourceT, ResourcePtrT> RO;
+ using RO = ResourceOwnerImpl<ResourceT, ResourcePtrT>;
return llvm::make_unique<RO>(std::move(ResourcePtr));
}
@@ -130,21 +137,21 @@ private:
};
struct LogicalDylib {
- typedef std::function<JITSymbol(const std::string&)> SymbolResolverFtor;
+ using SymbolResolverFtor = std::function<JITSymbol(const std::string&)>;
- typedef std::function<typename BaseLayerT::ModuleSetHandleT(
- BaseLayerT&,
- std::unique_ptr<Module>,
- std::unique_ptr<JITSymbolResolver>)>
- ModuleAdderFtor;
+ using ModuleAdderFtor =
+ std::function<typename BaseLayerT::ModuleHandleT(
+ BaseLayerT&,
+ std::unique_ptr<Module>,
+ std::unique_ptr<JITSymbolResolver>)>;
struct SourceModuleEntry {
std::unique_ptr<ResourceOwner<Module>> SourceMod;
std::set<Function*> StubsToClone;
};
- typedef std::vector<SourceModuleEntry> SourceModulesList;
- typedef typename SourceModulesList::size_type SourceModuleHandle;
+ using SourceModulesList = std::vector<SourceModuleEntry>;
+ using SourceModuleHandle = typename SourceModulesList::size_type;
SourceModuleHandle
addSourceModule(std::unique_ptr<ResourceOwner<Module>> M) {
@@ -174,7 +181,7 @@ private:
void removeModulesFromBaseLayer(BaseLayerT &BaseLayer) {
for (auto &BLH : BaseLayerHandles)
- BaseLayer.removeModuleSet(BLH);
+ BaseLayer.removeModule(BLH);
}
std::unique_ptr<JITSymbolResolver> ExternalSymbolResolver;
@@ -183,21 +190,21 @@ private:
StaticGlobalRenamer StaticRenamer;
ModuleAdderFtor ModuleAdder;
SourceModulesList SourceModules;
- std::vector<BaseLayerModuleSetHandleT> BaseLayerHandles;
+ std::vector<BaseLayerModuleHandleT> BaseLayerHandles;
};
- typedef std::list<LogicalDylib> LogicalDylibList;
+ using LogicalDylibList = std::list<LogicalDylib>;
public:
- /// @brief Handle to a set of loaded modules.
- typedef typename LogicalDylibList::iterator ModuleSetHandleT;
+ /// @brief Handle to loaded module.
+ using ModuleHandleT = typename LogicalDylibList::iterator;
/// @brief Module partitioning functor.
- typedef std::function<std::set<Function*>(Function&)> PartitioningFtor;
+ using PartitioningFtor = std::function<std::set<Function*>(Function&)>;
/// @brief Builder for IndirectStubsManagers.
- typedef std::function<std::unique_ptr<IndirectStubsMgrT>()>
- IndirectStubsManagerBuilderT;
+ using IndirectStubsManagerBuilderT =
+ std::function<std::unique_ptr<IndirectStubsMgrT>()>;
/// @brief Construct a compile-on-demand layer instance.
CompileOnDemandLayer(BaseLayerT &BaseLayer, PartitioningFtor Partition,
@@ -211,15 +218,14 @@ public:
~CompileOnDemandLayer() {
while (!LogicalDylibs.empty())
- removeModuleSet(LogicalDylibs.begin());
+ removeModule(LogicalDylibs.begin());
}
-
+
/// @brief Add a module to the compile-on-demand layer.
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- ModuleSetHandleT addModuleSet(ModuleSetT Ms,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ ModuleHandleT addModule(std::shared_ptr<Module> M,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
LogicalDylibs.push_back(LogicalDylib());
auto &LD = LogicalDylibs.back();
@@ -232,23 +238,25 @@ public:
LD.ModuleAdder =
[&MemMgrRef](BaseLayerT &B, std::unique_ptr<Module> M,
std::unique_ptr<JITSymbolResolver> R) {
- std::vector<std::unique_ptr<Module>> Ms;
- Ms.push_back(std::move(M));
- return B.addModuleSet(std::move(Ms), &MemMgrRef, std::move(R));
+ return B.addModule(std::move(M), &MemMgrRef, std::move(R));
};
// Process each of the modules in this module set.
- for (auto &M : Ms)
- addLogicalModule(LogicalDylibs.back(), std::move(M));
+ addLogicalModule(LogicalDylibs.back(), std::move(M));
return std::prev(LogicalDylibs.end());
}
+ /// @brief Add extra modules to an existing logical module.
+ void addExtraModule(ModuleHandleT H, std::shared_ptr<Module> M) {
+ addLogicalModule(*H, std::move(M));
+ }
+
/// @brief Remove the module represented by the given handle.
///
/// This will remove all modules in the layers below that were derived from
/// the module represented by H.
- void removeModuleSet(ModuleSetHandleT H) {
+ void removeModule(ModuleHandleT H) {
H->removeModulesFromBaseLayer(BaseLayer);
LogicalDylibs.erase(H);
}
@@ -270,7 +278,7 @@ public:
/// @brief Get the address of a symbol provided by this layer, or some layer
/// below this one.
- JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+ JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return H->findSymbol(BaseLayer, Name, ExportedSymbolsOnly);
}
@@ -303,7 +311,6 @@ public:
private:
template <typename ModulePtrT>
void addLogicalModule(LogicalDylib &LD, ModulePtrT SrcMPtr) {
-
// Rename all static functions / globals to $static.X :
// This will unique the names across all modules in the logical dylib,
// simplifying symbol lookup.
@@ -495,7 +502,7 @@ private:
}
template <typename PartitionT>
- BaseLayerModuleSetHandleT
+ BaseLayerModuleHandleT
emitPartition(LogicalDylib &LD,
typename LogicalDylib::SourceModuleHandle LMId,
const PartitionT &Part) {
@@ -581,6 +588,7 @@ private:
};
} // end namespace orc
+
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEONDEMANDLAYER_H
diff --git a/include/llvm/ExecutionEngine/Orc/CompileUtils.h b/include/llvm/ExecutionEngine/Orc/CompileUtils.h
index ce0864fbd9c9..b9f7d6accc30 100644
--- a/include/llvm/ExecutionEngine/Orc/CompileUtils.h
+++ b/include/llvm/ExecutionEngine/Orc/CompileUtils.h
@@ -1,4 +1,4 @@
-//===-- CompileUtils.h - Utilities for compiling IR in the JIT --*- C++ -*-===//
+//===- CompileUtils.h - Utilities for compiling IR in the JIT ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,24 +14,47 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h"
#include "llvm/IR/LegacyPassManager.h"
-#include "llvm/MC/MCContext.h"
+#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
+#include <algorithm>
+#include <memory>
namespace llvm {
+
+class MCContext;
+class Module;
+
namespace orc {
/// @brief Simple compile functor: Takes a single IR module and returns an
/// ObjectFile.
class SimpleCompiler {
public:
+
+ using CompileResult = object::OwningBinary<object::ObjectFile>;
+
/// @brief Construct a simple compile functor with the given target.
- SimpleCompiler(TargetMachine &TM) : TM(TM) {}
+ SimpleCompiler(TargetMachine &TM, ObjectCache *ObjCache = nullptr)
+ : TM(TM), ObjCache(ObjCache) {}
+
+ /// @brief Set an ObjectCache to query before compiling.
+ void setObjectCache(ObjectCache *NewCache) { ObjCache = NewCache; }
/// @brief Compile a Module to an ObjectFile.
- object::OwningBinary<object::ObjectFile> operator()(Module &M) const {
+ CompileResult operator()(Module &M) {
+ CompileResult CachedObject = tryToLoadFromObjectCache(M);
+ if (CachedObject.getBinary())
+ return CachedObject;
+
SmallVector<char, 0> ObjBufferSV;
raw_svector_ostream ObjStream(ObjBufferSV);
@@ -44,19 +67,47 @@ public:
new ObjectMemoryBuffer(std::move(ObjBufferSV)));
Expected<std::unique_ptr<object::ObjectFile>> Obj =
object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
- typedef object::OwningBinary<object::ObjectFile> OwningObj;
- if (Obj)
- return OwningObj(std::move(*Obj), std::move(ObjBuffer));
+ if (Obj) {
+ notifyObjectCompiled(M, *ObjBuffer);
+ return CompileResult(std::move(*Obj), std::move(ObjBuffer));
+ }
// TODO: Actually report errors helpfully.
consumeError(Obj.takeError());
- return OwningObj(nullptr, nullptr);
+ return CompileResult(nullptr, nullptr);
}
private:
+
+ CompileResult tryToLoadFromObjectCache(const Module &M) {
+ if (!ObjCache)
+ return CompileResult();
+
+ std::unique_ptr<MemoryBuffer> ObjBuffer = ObjCache->getObject(&M);
+ if (!ObjBuffer)
+ return CompileResult();
+
+ Expected<std::unique_ptr<object::ObjectFile>> Obj =
+ object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
+ if (!Obj) {
+ // TODO: Actually report errors helpfully.
+ consumeError(Obj.takeError());
+ return CompileResult();
+ }
+
+ return CompileResult(std::move(*Obj), std::move(ObjBuffer));
+ }
+
+ void notifyObjectCompiled(const Module &M, const MemoryBuffer &ObjBuffer) {
+ if (ObjCache)
+ ObjCache->notifyObjectCompiled(&M, ObjBuffer.getMemBufferRef());
+ }
+
TargetMachine &TM;
+ ObjectCache *ObjCache = nullptr;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_COMPILEUTILS_H
diff --git a/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h b/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
index 71d847c06264..bf8cca406844 100644
--- a/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
+++ b/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
@@ -1,4 +1,4 @@
-//===-- ExecutionUtils.h - Utilities for executing code in Orc --*- C++ -*-===//
+//===- ExecutionUtils.h - Utilities for executing code in Orc ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,8 +17,11 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include <algorithm>
+#include <cstdint>
+#include <string>
#include <vector>
+#include <utility>
namespace llvm {
@@ -37,7 +40,6 @@ namespace orc {
/// getConstructors/getDestructors functions.
class CtorDtorIterator {
public:
-
/// @brief Accessor for an element of the global_ctors/global_dtors array.
///
/// This class provides a read-only view of the element with any casts on
@@ -89,17 +91,16 @@ iterator_range<CtorDtorIterator> getDestructors(const Module &M);
template <typename JITLayerT>
class CtorDtorRunner {
public:
-
/// @brief Construct a CtorDtorRunner for the given range using the given
/// name mangling function.
CtorDtorRunner(std::vector<std::string> CtorDtorNames,
- typename JITLayerT::ModuleSetHandleT H)
+ typename JITLayerT::ModuleHandleT H)
: CtorDtorNames(std::move(CtorDtorNames)), H(H) {}
/// @brief Run the recorded constructors/destructors through the given JIT
/// layer.
bool runViaLayer(JITLayerT &JITLayer) const {
- typedef void (*CtorDtorTy)();
+ using CtorDtorTy = void (*)();
bool Error = false;
for (const auto &CtorDtorName : CtorDtorNames)
@@ -115,7 +116,7 @@ public:
private:
std::vector<std::string> CtorDtorNames;
- typename JITLayerT::ModuleSetHandleT H;
+ typename JITLayerT::ModuleHandleT H;
};
/// @brief Support class for static dtor execution. For hosted (in-process) JITs
@@ -135,7 +136,6 @@ private:
/// called.
class LocalCXXRuntimeOverrides {
public:
-
/// Create a runtime-overrides class.
template <typename MangleFtorT>
LocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
@@ -156,7 +156,6 @@ public:
void runDestructors();
private:
-
template <typename PtrTy>
JITTargetAddress toTargetAddress(PtrTy* P) {
return static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(P));
@@ -168,15 +167,16 @@ private:
StringMap<JITTargetAddress> CXXRuntimeOverrides;
- typedef void (*DestructorPtr)(void*);
- typedef std::pair<DestructorPtr, void*> CXXDestructorDataPair;
- typedef std::vector<CXXDestructorDataPair> CXXDestructorDataPairList;
+ using DestructorPtr = void (*)(void *);
+ using CXXDestructorDataPair = std::pair<DestructorPtr, void *>;
+ using CXXDestructorDataPairList = std::vector<CXXDestructorDataPair>;
CXXDestructorDataPairList DSOHandleOverride;
static int CXAAtExitOverride(DestructorPtr Destructor, void *Arg,
void *DSOHandle);
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
diff --git a/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h b/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h
index 634d1480ae4c..d582e9a33241 100644
--- a/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/GlobalMappingLayer.h
@@ -1,4 +1,4 @@
-//===---- GlobalMappingLayer.h - Run all IR through a functor ---*- C++ -*-===//
+//===- GlobalMappingLayer.h - Run all IR through a functor ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,6 +17,7 @@
#include "llvm/ExecutionEngine/JITSymbol.h"
#include <map>
+#include <string>
namespace llvm {
namespace orc {
@@ -32,7 +33,7 @@ template <typename BaseLayerT>
class GlobalMappingLayer {
public:
/// @brief Handle to a set of added modules.
- typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
+ using ModuleSetHandleT = typename BaseLayerT::ModuleSetHandleT;
/// @brief Construct an GlobalMappingLayer with the given BaseLayer
GlobalMappingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
@@ -102,7 +103,7 @@ private:
std::map<std::string, JITTargetAddress> SymbolTable;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H
diff --git a/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h b/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
index f81d054440fc..99ccd4d221a5 100644
--- a/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
@@ -1,4 +1,4 @@
-//===------ IRCompileLayer.h -- Eagerly compile IR for JIT ------*- C++ -*-===//
+//===- IRCompileLayer.h -- Eagerly compile IR for JIT -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,79 +14,54 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
#define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/ExecutionEngine/ObjectCache.h"
-#include "llvm/Object/ObjectFile.h"
+#include "llvm/Support/Error.h"
#include <memory>
+#include <string>
namespace llvm {
+
+class Module;
+
namespace orc {
/// @brief Eager IR compiling layer.
///
-/// This layer accepts sets of LLVM IR Modules (via addModuleSet). It
-/// immediately compiles each IR module to an object file (each IR Module is
-/// compiled separately). The resulting set of object files is then added to
-/// the layer below, which must implement the object layer concept.
-template <typename BaseLayerT> class IRCompileLayer {
+/// This layer immediately compiles each IR module added via addModule to an
+/// object file and adds this module file to the layer below, which must
+/// implement the object layer concept.
+template <typename BaseLayerT, typename CompileFtor>
+class IRCompileLayer {
public:
- typedef std::function<object::OwningBinary<object::ObjectFile>(Module &)>
- CompileFtor;
-
-private:
- typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
-public:
- /// @brief Handle to a set of compiled modules.
- typedef ObjSetHandleT ModuleSetHandleT;
+ /// @brief Handle to a compiled module.
+ using ModuleHandleT = typename BaseLayerT::ObjHandleT;
/// @brief Construct an IRCompileLayer with the given BaseLayer, which must
/// implement the ObjectLayer concept.
IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile)
- : BaseLayer(BaseLayer), Compile(std::move(Compile)), ObjCache(nullptr) {}
+ : BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
- /// @brief Set an ObjectCache to query before compiling.
- void setObjectCache(ObjectCache *NewCache) { ObjCache = NewCache; }
+ /// @brief Get a reference to the compiler functor.
+ CompileFtor& getCompiler() { return Compile; }
- /// @brief Compile each module in the given module set, then add the resulting
- /// set of objects to the base layer along with the memory manager and
- /// symbol resolver.
+ /// @brief Compile the module, and add the resulting object to the base layer
+ /// along with the given memory manager and symbol resolver.
///
- /// @return A handle for the added modules.
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- ModuleSetHandleT addModuleSet(ModuleSetT Ms,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
- std::vector<std::unique_ptr<object::OwningBinary<object::ObjectFile>>>
- Objects;
-
- for (const auto &M : Ms) {
- auto Object =
- llvm::make_unique<object::OwningBinary<object::ObjectFile>>();
-
- if (ObjCache)
- *Object = tryToLoadFromObjectCache(*M);
-
- if (!Object->getBinary()) {
- *Object = Compile(*M);
- if (ObjCache)
- ObjCache->notifyObjectCompiled(&*M,
- Object->getBinary()->getMemoryBufferRef());
- }
-
- Objects.push_back(std::move(Object));
- }
-
- ModuleSetHandleT H =
- BaseLayer.addObjectSet(std::move(Objects), std::move(MemMgr),
- std::move(Resolver));
-
- return H;
+ /// @return A handle for the added module.
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ ModuleHandleT addModule(std::shared_ptr<Module> M,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
+ using CompileResult = decltype(Compile(*M));
+ auto Obj = std::make_shared<CompileResult>(Compile(*M));
+ return BaseLayer.addObject(std::move(Obj), std::move(MemMgr),
+ std::move(Resolver));
}
- /// @brief Remove the module set associated with the handle H.
- void removeModuleSet(ModuleSetHandleT H) { BaseLayer.removeObjectSet(H); }
+ /// @brief Remove the module associated with the handle H.
+ void removeModule(ModuleHandleT H) { BaseLayer.removeObject(H); }
/// @brief Search for the given named symbol.
/// @param Name The name of the symbol to search for.
@@ -96,51 +71,33 @@ public:
return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
}
- /// @brief Get the address of the given symbol in the context of the set of
- /// compiled modules represented by the handle H. This call is
- /// forwarded to the base layer's implementation.
- /// @param H The handle for the module set to search in.
+ /// @brief Get the address of the given symbol in compiled module represented
+ /// by the handle H. This call is forwarded to the base layer's
+ /// implementation.
+ /// @param H The handle for the module to search in.
/// @param Name The name of the symbol to search for.
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
/// @return A handle for the given named symbol, if it is found in the
- /// given module set.
- JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+ /// given module.
+ JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
}
- /// @brief Immediately emit and finalize the moduleOB set represented by the
- /// given handle.
- /// @param H Handle for module set to emit/finalize.
- void emitAndFinalize(ModuleSetHandleT H) {
+ /// @brief Immediately emit and finalize the module represented by the given
+ /// handle.
+ /// @param H Handle for module to emit/finalize.
+ void emitAndFinalize(ModuleHandleT H) {
BaseLayer.emitAndFinalize(H);
}
private:
- object::OwningBinary<object::ObjectFile>
- tryToLoadFromObjectCache(const Module &M) {
- std::unique_ptr<MemoryBuffer> ObjBuffer = ObjCache->getObject(&M);
- if (!ObjBuffer)
- return object::OwningBinary<object::ObjectFile>();
-
- Expected<std::unique_ptr<object::ObjectFile>> Obj =
- object::ObjectFile::createObjectFile(ObjBuffer->getMemBufferRef());
- if (!Obj) {
- // TODO: Actually report errors helpfully.
- consumeError(Obj.takeError());
- return object::OwningBinary<object::ObjectFile>();
- }
-
- return object::OwningBinary<object::ObjectFile>(std::move(*Obj),
- std::move(ObjBuffer));
- }
-
BaseLayerT &BaseLayer;
CompileFtor Compile;
- ObjectCache *ObjCache;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_IRCOMPILINGLAYER_H
diff --git a/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h b/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
index c67297b111b9..8e9be6b6f4fe 100644
--- a/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
@@ -1,4 +1,4 @@
-//===----- IRTransformLayer.h - Run all IR through a functor ----*- C++ -*-===//
+//===- IRTransformLayer.h - Run all IR through a functor --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,46 +15,41 @@
#define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include <string>
namespace llvm {
namespace orc {
/// @brief IR mutating layer.
///
-/// This layer accepts sets of LLVM IR Modules (via addModuleSet). It
-/// immediately applies the user supplied functor to each module, then adds
-/// the set of transformed modules to the layer below.
+/// This layer applies a user supplied transform to each module that is added,
+/// then adds the transformed module to the layer below.
template <typename BaseLayerT, typename TransformFtor>
class IRTransformLayer {
public:
+
/// @brief Handle to a set of added modules.
- typedef typename BaseLayerT::ModuleSetHandleT ModuleSetHandleT;
+ using ModuleHandleT = typename BaseLayerT::ModuleHandleT;
/// @brief Construct an IRTransformLayer with the given BaseLayer
IRTransformLayer(BaseLayerT &BaseLayer,
TransformFtor Transform = TransformFtor())
: BaseLayer(BaseLayer), Transform(std::move(Transform)) {}
- /// @brief Apply the transform functor to each module in the module set, then
- /// add the resulting set of modules to the base layer, along with the
- /// memory manager and symbol resolver.
+ /// @brief Apply the transform functor to the module, then add the module to
+ /// the layer below, along with the memory manager and symbol resolver.
///
/// @return A handle for the added modules.
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- ModuleSetHandleT addModuleSet(ModuleSetT Ms,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
-
- for (auto I = Ms.begin(), E = Ms.end(); I != E; ++I)
- *I = Transform(std::move(*I));
-
- return BaseLayer.addModuleSet(std::move(Ms), std::move(MemMgr),
- std::move(Resolver));
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ ModuleHandleT addModule(std::shared_ptr<Module> M,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
+ return BaseLayer.addModule(Transform(std::move(M)), std::move(MemMgr),
+ std::move(Resolver));
}
- /// @brief Remove the module set associated with the handle H.
- void removeModuleSet(ModuleSetHandleT H) { BaseLayer.removeModuleSet(H); }
+ /// @brief Remove the module associated with the handle H.
+ void removeModule(ModuleHandleT H) { BaseLayer.removeModule(H); }
/// @brief Search for the given named symbol.
/// @param Name The name of the symbol to search for.
@@ -64,23 +59,23 @@ public:
return BaseLayer.findSymbol(Name, ExportedSymbolsOnly);
}
- /// @brief Get the address of the given symbol in the context of the set of
- /// modules represented by the handle H. This call is forwarded to the
- /// base layer's implementation.
- /// @param H The handle for the module set to search in.
+ /// @brief Get the address of the given symbol in the context of the module
+ /// represented by the handle H. This call is forwarded to the base
+ /// layer's implementation.
+ /// @param H The handle for the module to search in.
/// @param Name The name of the symbol to search for.
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
/// @return A handle for the given named symbol, if it is found in the
- /// given module set.
- JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+ /// given module.
+ JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
}
- /// @brief Immediately emit and finalize the module set represented by the
- /// given handle.
- /// @param H Handle for module set to emit/finalize.
- void emitAndFinalize(ModuleSetHandleT H) {
+ /// @brief Immediately emit and finalize the module represented by the given
+ /// handle.
+ /// @param H Handle for module to emit/finalize.
+ void emitAndFinalize(ModuleHandleT H) {
BaseLayer.emitAndFinalize(H);
}
@@ -95,7 +90,7 @@ private:
TransformFtor Transform;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
diff --git a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
index 07bbd921dad6..e038093d7628 100644
--- a/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
+++ b/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
@@ -1,4 +1,4 @@
-//===-- IndirectionUtils.h - Utilities for adding indirections --*- C++ -*-===//
+//===- IndirectionUtils.h - Utilities for adding indirections ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,9 +18,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
-#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/Mangler.h"
-#include "llvm/IR/Module.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Process.h"
@@ -36,12 +33,23 @@
#include <vector>
namespace llvm {
+
+class Constant;
+class Function;
+class FunctionType;
+class GlobalAlias;
+class GlobalVariable;
+class Module;
+class PointerType;
+class Triple;
+class Value;
+
namespace orc {
/// @brief Target-independent base class for compile callback management.
class JITCompileCallbackManager {
public:
- typedef std::function<JITTargetAddress()> CompileFtor;
+ using CompileFtor = std::function<JITTargetAddress()>;
/// @brief Handle to a newly created compile callback. Can be used to get an
/// IR constant representing the address of the trampoline, and to set
@@ -125,7 +133,7 @@ public:
protected:
JITTargetAddress ErrorHandlerAddress;
- typedef std::map<JITTargetAddress, CompileFtor> TrampolineMapT;
+ using TrampolineMapT = std::map<JITTargetAddress, CompileFtor>;
TrampolineMapT ActiveTrampolines;
std::vector<JITTargetAddress> AvailableTrampolines;
@@ -155,7 +163,6 @@ public:
/// process to be used if a compile callback fails.
LocalJITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: JITCompileCallbackManager(ErrorHandlerAddress) {
-
/// Set up the resolver block.
std::error_code EC;
ResolverBlock = sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
@@ -220,7 +227,7 @@ private:
class IndirectStubsManager {
public:
/// @brief Map type for initializing the manager. See init.
- typedef StringMap<std::pair<JITTargetAddress, JITSymbolFlags>> StubInitsMap;
+ using StubInitsMap = StringMap<std::pair<JITTargetAddress, JITSymbolFlags>>;
virtual ~IndirectStubsManager() = default;
@@ -336,7 +343,7 @@ private:
}
std::vector<typename TargetT::IndirectStubsInfo> IndirectStubsInfos;
- typedef std::pair<uint16_t, uint16_t> StubKey;
+ using StubKey = std::pair<uint16_t, uint16_t>;
std::vector<StubKey> FreeStubs;
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
};
@@ -432,6 +439,7 @@ void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
ValueToValueMapTy &VMap);
} // end namespace orc
+
} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
diff --git a/include/llvm/ExecutionEngine/Orc/LambdaResolver.h b/include/llvm/ExecutionEngine/Orc/LambdaResolver.h
index cbe2a80edf1c..6868640d38e8 100644
--- a/include/llvm/ExecutionEngine/Orc/LambdaResolver.h
+++ b/include/llvm/ExecutionEngine/Orc/LambdaResolver.h
@@ -1,4 +1,4 @@
-//===-- LambdaResolverMM - Redirect symbol lookup via a functor -*- C++ -*-===//
+//===- LambdaResolverMM - Redirect symbol lookup via a functor --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,7 +16,7 @@
#define LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ExecutionEngine/RuntimeDyld.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
#include <memory>
namespace llvm {
@@ -25,7 +25,6 @@ namespace orc {
template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
class LambdaResolver : public JITSymbolResolver {
public:
-
LambdaResolver(DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor)
: DylibLookupFtor(DylibLookupFtor),
@@ -49,12 +48,12 @@ template <typename DylibLookupFtorT,
std::unique_ptr<LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>>
createLambdaResolver(DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor) {
- typedef LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT> LR;
+ using LR = LambdaResolver<DylibLookupFtorT, ExternalLookupFtorT>;
return make_unique<LR>(std::move(DylibLookupFtor),
std::move(ExternalLookupFtor));
}
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_LAMBDARESOLVER_H
diff --git a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
index 53d4c0cfe5d4..38769aac12af 100644
--- a/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
@@ -34,19 +34,20 @@ namespace orc {
/// @brief Lazy-emitting IR layer.
///
-/// This layer accepts sets of LLVM IR Modules (via addModuleSet), but does
-/// not immediately emit them the layer below. Instead, emissing to the base
-/// layer is deferred until the first time the client requests the address
-/// (via JITSymbol::getAddress) for a symbol contained in this layer.
+/// This layer accepts LLVM IR Modules (via addModule), but does not
+/// immediately emit them the layer below. Instead, emissing to the base layer
+/// is deferred until the first time the client requests the address (via
+/// JITSymbol::getAddress) for a symbol contained in this layer.
template <typename BaseLayerT> class LazyEmittingLayer {
public:
- typedef typename BaseLayerT::ModuleSetHandleT BaseLayerHandleT;
+
+ using BaseLayerHandleT = typename BaseLayerT::ModuleHandleT;
private:
- class EmissionDeferredSet {
+ class EmissionDeferredModule {
public:
- EmissionDeferredSet() = default;
- virtual ~EmissionDeferredSet() = default;
+ EmissionDeferredModule() = default;
+ virtual ~EmissionDeferredModule() = default;
JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) {
switch (EmitState) {
@@ -84,9 +85,9 @@ private:
llvm_unreachable("Invalid emit-state.");
}
- void removeModulesFromBaseLayer(BaseLayerT &BaseLayer) {
+ void removeModuleFromBaseLayer(BaseLayerT &BaseLayer) {
if (EmitState != NotEmitted)
- BaseLayer.removeModuleSet(Handle);
+ BaseLayer.removeModule(Handle);
}
void emitAndFinalize(BaseLayerT &BaseLayer) {
@@ -100,10 +101,9 @@ private:
BaseLayer.emitAndFinalize(Handle);
}
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- static std::unique_ptr<EmissionDeferredSet>
- create(BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ static std::unique_ptr<EmissionDeferredModule>
+ create(BaseLayerT &B, std::shared_ptr<Module> M, MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver);
protected:
@@ -116,14 +116,13 @@ private:
BaseLayerHandleT Handle;
};
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- class EmissionDeferredSetImpl : public EmissionDeferredSet {
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ class EmissionDeferredModuleImpl : public EmissionDeferredModule {
public:
- EmissionDeferredSetImpl(ModuleSetT Ms,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver)
- : Ms(std::move(Ms)), MemMgr(std::move(MemMgr)),
+ EmissionDeferredModuleImpl(std::shared_ptr<Module> M,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver)
+ : M(std::move(M)), MemMgr(std::move(MemMgr)),
Resolver(std::move(Resolver)) {}
protected:
@@ -154,8 +153,8 @@ private:
// We don't need the mangled names set any more: Once we've emitted this
// to the base layer we'll just look for symbols there.
MangledSymbols.reset();
- return BaseLayer.addModuleSet(std::move(Ms), std::move(MemMgr),
- std::move(Resolver));
+ return BaseLayer.addModule(std::move(M), std::move(MemMgr),
+ std::move(Resolver));
}
private:
@@ -197,56 +196,54 @@ private:
auto Symbols = llvm::make_unique<StringMap<const GlobalValue*>>();
- for (const auto &M : Ms) {
- Mangler Mang;
+ Mangler Mang;
- for (const auto &GO : M->global_objects())
+ for (const auto &GO : M->global_objects())
if (auto GV = addGlobalValue(*Symbols, GO, Mang, SearchName,
ExportedSymbolsOnly))
return GV;
- }
MangledSymbols = std::move(Symbols);
return nullptr;
}
- ModuleSetT Ms;
+ std::shared_ptr<Module> M;
MemoryManagerPtrT MemMgr;
SymbolResolverPtrT Resolver;
mutable std::unique_ptr<StringMap<const GlobalValue*>> MangledSymbols;
};
- typedef std::list<std::unique_ptr<EmissionDeferredSet>> ModuleSetListT;
+ using ModuleListT = std::list<std::unique_ptr<EmissionDeferredModule>>;
BaseLayerT &BaseLayer;
- ModuleSetListT ModuleSetList;
+ ModuleListT ModuleList;
public:
- /// @brief Handle to a set of loaded modules.
- typedef typename ModuleSetListT::iterator ModuleSetHandleT;
+ /// @brief Handle to a loaded module.
+ using ModuleHandleT = typename ModuleListT::iterator;
/// @brief Construct a lazy emitting layer.
LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
- /// @brief Add the given set of modules to the lazy emitting layer.
- template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
- ModuleSetHandleT addModuleSet(ModuleSetT Ms,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
- return ModuleSetList.insert(
- ModuleSetList.end(),
- EmissionDeferredSet::create(BaseLayer, std::move(Ms), std::move(MemMgr),
- std::move(Resolver)));
+ /// @brief Add the given module to the lazy emitting layer.
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+ ModuleHandleT addModule(std::shared_ptr<Module> M,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
+ return ModuleList.insert(
+ ModuleList.end(),
+ EmissionDeferredModule::create(BaseLayer, std::move(M),
+ std::move(MemMgr),
+ std::move(Resolver)));
}
- /// @brief Remove the module set represented by the given handle.
+ /// @brief Remove the module represented by the given handle.
///
- /// This method will free the memory associated with the given module set,
- /// both in this layer, and the base layer.
- void removeModuleSet(ModuleSetHandleT H) {
- (*H)->removeModulesFromBaseLayer(BaseLayer);
- ModuleSetList.erase(H);
+ /// This method will free the memory associated with the given module, both
+ /// in this layer, and the base layer.
+ void removeModule(ModuleHandleT H) {
+ (*H)->removeModuleFromBaseLayer(BaseLayer);
+ ModuleList.erase(H);
}
/// @brief Search for the given named symbol.
@@ -258,42 +255,40 @@ public:
if (auto Symbol = BaseLayer.findSymbol(Name, ExportedSymbolsOnly))
return Symbol;
- // If not found then search the deferred sets. If any of these contain a
+ // If not found then search the deferred modules. If any of these contain a
// definition of 'Name' then they will return a JITSymbol that will emit
// the corresponding module when the symbol address is requested.
- for (auto &DeferredSet : ModuleSetList)
- if (auto Symbol = DeferredSet->find(Name, ExportedSymbolsOnly, BaseLayer))
+ for (auto &DeferredMod : ModuleList)
+ if (auto Symbol = DeferredMod->find(Name, ExportedSymbolsOnly, BaseLayer))
return Symbol;
// If no definition found anywhere return a null symbol.
return nullptr;
}
- /// @brief Get the address of the given symbol in the context of the set of
+ /// @brief Get the address of the given symbol in the context of the of
/// compiled modules represented by the handle H.
- JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
+ JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return (*H)->find(Name, ExportedSymbolsOnly, BaseLayer);
}
- /// @brief Immediately emit and finalize the moduleOB set represented by the
- /// given handle.
- /// @param H Handle for module set to emit/finalize.
- void emitAndFinalize(ModuleSetHandleT H) {
+ /// @brief Immediately emit and finalize the module represented by the given
+ /// handle.
+ /// @param H Handle for module to emit/finalize.
+ void emitAndFinalize(ModuleHandleT H) {
(*H)->emitAndFinalize(BaseLayer);
}
};
template <typename BaseLayerT>
-template <typename ModuleSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT>
-std::unique_ptr<typename LazyEmittingLayer<BaseLayerT>::EmissionDeferredSet>
-LazyEmittingLayer<BaseLayerT>::EmissionDeferredSet::create(
- BaseLayerT &B, ModuleSetT Ms, MemoryManagerPtrT MemMgr,
+template <typename MemoryManagerPtrT, typename SymbolResolverPtrT>
+std::unique_ptr<typename LazyEmittingLayer<BaseLayerT>::EmissionDeferredModule>
+LazyEmittingLayer<BaseLayerT>::EmissionDeferredModule::create(
+ BaseLayerT &B, std::shared_ptr<Module> M, MemoryManagerPtrT MemMgr,
SymbolResolverPtrT Resolver) {
- typedef EmissionDeferredSetImpl<ModuleSetT, MemoryManagerPtrT, SymbolResolverPtrT>
- EDS;
- return llvm::make_unique<EDS>(std::move(Ms), std::move(MemMgr),
+ using EDS = EmissionDeferredModuleImpl<MemoryManagerPtrT, SymbolResolverPtrT>;
+ return llvm::make_unique<EDS>(std::move(M), std::move(MemMgr),
std::move(Resolver));
}
diff --git a/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h b/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
index 173c106cd3ec..c41c1233c0d9 100644
--- a/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
@@ -15,20 +15,22 @@
#define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include <algorithm>
+#include <string>
namespace llvm {
namespace orc {
/// @brief Object mutating layer.
///
-/// This layer accepts sets of ObjectFiles (via addObjectSet). It
+/// This layer accepts sets of ObjectFiles (via addObject). It
/// immediately applies the user supplied functor to each object, then adds
/// the set of transformed objects to the layer below.
template <typename BaseLayerT, typename TransformFtor>
class ObjectTransformLayer {
public:
/// @brief Handle to a set of added objects.
- typedef typename BaseLayerT::ObjSetHandleT ObjSetHandleT;
+ using ObjHandleT = typename BaseLayerT::ObjHandleT;
/// @brief Construct an ObjectTransformLayer with the given BaseLayer
ObjectTransformLayer(BaseLayerT &BaseLayer,
@@ -40,20 +42,16 @@ public:
/// memory manager and symbol resolver.
///
/// @return A handle for the added objects.
- template <typename ObjSetT, typename MemoryManagerPtrT,
+ template <typename ObjPtrT, typename MemoryManagerPtrT,
typename SymbolResolverPtrT>
- ObjSetHandleT addObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
-
- for (auto I = Objects.begin(), E = Objects.end(); I != E; ++I)
- *I = Transform(std::move(*I));
-
- return BaseLayer.addObjectSet(std::move(Objects), std::move(MemMgr),
- std::move(Resolver));
+ ObjHandleT addObject(ObjPtrT Obj, MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
+ return BaseLayer.addObject(Transform(std::move(Obj)), std::move(MemMgr),
+ std::move(Resolver));
}
/// @brief Remove the object set associated with the handle H.
- void removeObjectSet(ObjSetHandleT H) { BaseLayer.removeObjectSet(H); }
+ void removeObject(ObjHandleT H) { BaseLayer.removeObject(H); }
/// @brief Search for the given named symbol.
/// @param Name The name of the symbol to search for.
@@ -71,7 +69,7 @@ public:
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
/// @return A handle for the given named symbol, if it is found in the
/// given object set.
- JITSymbol findSymbolIn(ObjSetHandleT H, const std::string &Name,
+ JITSymbol findSymbolIn(ObjHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) {
return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
}
@@ -79,10 +77,10 @@ public:
/// @brief Immediately emit and finalize the object set represented by the
/// given handle.
/// @param H Handle for object set to emit/finalize.
- void emitAndFinalize(ObjSetHandleT H) { BaseLayer.emitAndFinalize(H); }
+ void emitAndFinalize(ObjHandleT H) { BaseLayer.emitAndFinalize(H); }
/// @brief Map section addresses for the objects associated with the handle H.
- void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
+ void mapSectionAddress(ObjHandleT H, const void *LocalAddress,
JITTargetAddress TargetAddr) {
BaseLayer.mapSectionAddress(H, LocalAddress, TargetAddr);
}
@@ -98,7 +96,7 @@ private:
TransformFtor Transform;
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
diff --git a/include/llvm/ExecutionEngine/Orc/OrcABISupport.h b/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
index fa236b0de88a..e1b55649b9f2 100644
--- a/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
+++ b/include/llvm/ExecutionEngine/Orc/OrcABISupport.h
@@ -1,4 +1,4 @@
-//===-------------- OrcABISupport.h - ABI support code ---------*- C++ -*-===//
+//===- OrcABISupport.h - ABI support code -----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,9 +18,12 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
#define LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
-#include "IndirectionUtils.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h"
-#include "llvm/Support/Process.h"
+#include <algorithm>
+#include <cstdint>
namespace llvm {
namespace orc {
@@ -37,8 +40,8 @@ public:
static const unsigned TrampolineSize = 1;
static const unsigned ResolverCodeSize = 1;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
void *CallbackMgr) {
@@ -55,6 +58,7 @@ public:
class IndirectStubsInfo {
public:
const static unsigned StubSize = 1;
+
unsigned getNumStubs() const { llvm_unreachable("Not supported"); }
void *getStub(unsigned Idx) const { llvm_unreachable("Not supported"); }
void **getPtr(unsigned Idx) const { llvm_unreachable("Not supported"); }
@@ -73,13 +77,14 @@ template <unsigned StubSizeVal> class GenericIndirectStubsInfo {
public:
const static unsigned StubSize = StubSizeVal;
- GenericIndirectStubsInfo() : NumStubs(0) {}
+ GenericIndirectStubsInfo() = default;
GenericIndirectStubsInfo(unsigned NumStubs, sys::OwningMemoryBlock StubsMem)
: NumStubs(NumStubs), StubsMem(std::move(StubsMem)) {}
GenericIndirectStubsInfo(GenericIndirectStubsInfo &&Other)
: NumStubs(Other.NumStubs), StubsMem(std::move(Other.StubsMem)) {
Other.NumStubs = 0;
}
+
GenericIndirectStubsInfo &operator=(GenericIndirectStubsInfo &&Other) {
NumStubs = Other.NumStubs;
Other.NumStubs = 0;
@@ -104,7 +109,7 @@ public:
}
private:
- unsigned NumStubs;
+ unsigned NumStubs = 0;
sys::OwningMemoryBlock StubsMem;
};
@@ -114,10 +119,10 @@ public:
static const unsigned TrampolineSize = 12;
static const unsigned ResolverCodeSize = 0x120;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
@@ -148,7 +153,7 @@ public:
static const unsigned PointerSize = 8;
static const unsigned TrampolineSize = 8;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
/// @brief Write the requsted number of trampolines into the given memory,
/// which must be big enough to hold 1 pointer, plus NumTrampolines
@@ -172,8 +177,9 @@ public:
class OrcX86_64_SysV : public OrcX86_64_Base {
public:
static const unsigned ResolverCodeSize = 0x6C;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
@@ -187,8 +193,9 @@ public:
class OrcX86_64_Win32 : public OrcX86_64_Base {
public:
static const unsigned ResolverCodeSize = 0x74;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
@@ -205,10 +212,10 @@ public:
static const unsigned TrampolineSize = 8;
static const unsigned ResolverCodeSize = 0x4a;
- typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
+ using IndirectStubsInfo = GenericIndirectStubsInfo<8>;
- typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
- void *TrampolineId);
+ using JITReentryFn = JITTargetAddress (*)(void *CallbackMgr,
+ void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions.
@@ -231,7 +238,7 @@ public:
unsigned MinStubs, void *InitialPtrVal);
};
-} // End namespace orc.
-} // End namespace llvm.
+} // end namespace orc
+} // end namespace llvm
#endif // LLVM_EXECUTIONENGINE_ORC_ORCABISUPPORT_H
diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
index a19c30631c57..da02250ba169 100644
--- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
+++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
@@ -1,4 +1,4 @@
-//===---- OrcRemoteTargetClient.h - Orc Remote-target Client ----*- C++ -*-===//
+//===- OrcRemoteTargetClient.h - Orc Remote-target Client -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,10 +16,29 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
-#include "IndirectionUtils.h"
-#include "OrcRemoteTargetRPCAPI.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
+#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
-#include <system_error>
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Memory.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <cstdint>
+#include <memory>
+#include <string>
+#include <tuple>
+#include <utility>
+#include <vector>
#define DEBUG_TYPE "orc-remote"
@@ -207,7 +226,6 @@ public:
DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n");
for (auto &ObjAllocs : Unfinalized) {
-
for (auto &Alloc : ObjAllocs.CodeAllocs) {
DEBUG(dbgs() << " copying code: "
<< static_cast<void *>(Alloc.getLocalAddress()) << " -> "
@@ -469,7 +487,7 @@ public:
OrcRemoteTargetClient &Remote;
ResourceIdMgr::ResourceId Id;
std::vector<RemoteIndirectStubsInfo> RemoteIndirectStubsInfos;
- typedef std::pair<uint16_t, uint16_t> StubKey;
+ using StubKey = std::pair<uint16_t, uint16_t>;
std::vector<StubKey> FreeStubs;
StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
@@ -710,7 +728,6 @@ private:
Expected<JITTargetAddress> reserveMem(ResourceIdMgr::ResourceId Id,
uint64_t Size, uint32_t Align) {
-
// Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError)
return std::move(ExistingError);
diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h
index 3086ef0cdf80..07ae7f04d1a0 100644
--- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h
+++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h
@@ -1,4 +1,4 @@
-//===--- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ----*- C++ -*-===//
+//===- OrcRemoteTargetRPCAPI.h - Orc Remote-target RPC API ------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,12 +16,13 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
-#include "RPCUtils.h"
-#include "RawByteChannel.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/RPCUtils.h"
+#include "llvm/ExecutionEngine/Orc/RawByteChannel.h"
namespace llvm {
namespace orc {
+
namespace remote {
class DirectBufferWriter {
@@ -72,7 +73,7 @@ public:
return EC;
char *Addr = reinterpret_cast<char *>(static_cast<uintptr_t>(Dst));
- DBW = remote::DirectBufferWriter(0, Dst, Size);
+ DBW = remote::DirectBufferWriter(nullptr, Dst, Size);
return C.readBytes(Addr, Size);
}
@@ -87,7 +88,7 @@ class OrcRemoteTargetRPCAPI
protected:
class ResourceIdMgr {
public:
- typedef uint64_t ResourceId;
+ using ResourceId = uint64_t;
static const ResourceId InvalidId = ~0U;
ResourceId getNext() {
@@ -98,6 +99,7 @@ protected:
}
return NextId++;
}
+
void release(ResourceId I) { FreeIds.push_back(I); }
private:
@@ -261,7 +263,8 @@ public:
};
} // end namespace remote
+
} // end namespace orc
} // end namespace llvm
-#endif
+#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
diff --git a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
index a61ff102be0b..e7b6d64931b6 100644
--- a/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
+++ b/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetServer.h
@@ -1,4 +1,4 @@
-//===---- OrcRemoteTargetServer.h - Orc Remote-target Server ----*- C++ -*-===//
+//===- OrcRemoteTargetServer.h - Orc Remote-target Server -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,10 +15,9 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
-#include "OrcRemoteTargetRPCAPI.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/OrcError.h"
-#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/OrcRemoteTargetRPCAPI.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Format.h"
@@ -48,20 +47,18 @@ namespace remote {
template <typename ChannelT, typename TargetT>
class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI {
public:
- typedef std::function<JITTargetAddress(const std::string &Name)>
- SymbolLookupFtor;
+ using SymbolLookupFtor =
+ std::function<JITTargetAddress(const std::string &Name)>;
- typedef std::function<void(uint8_t *Addr, uint32_t Size)>
- EHFrameRegistrationFtor;
+ using EHFrameRegistrationFtor =
+ std::function<void(uint8_t *Addr, uint32_t Size)>;
OrcRemoteTargetServer(ChannelT &Channel, SymbolLookupFtor SymbolLookup,
EHFrameRegistrationFtor EHFramesRegister,
EHFrameRegistrationFtor EHFramesDeregister)
: OrcRemoteTargetRPCAPI(Channel), SymbolLookup(std::move(SymbolLookup)),
EHFramesRegister(std::move(EHFramesRegister)),
- EHFramesDeregister(std::move(EHFramesDeregister)),
- TerminateFlag(false) {
-
+ EHFramesDeregister(std::move(EHFramesDeregister)) {
using ThisT = typename std::remove_reference<decltype(*this)>::type;
addHandler<CallIntVoid>(*this, &ThisT::handleCallIntVoid);
addHandler<CallMain>(*this, &ThisT::handleCallMain);
@@ -106,6 +103,7 @@ private:
struct Allocator {
Allocator() = default;
Allocator(Allocator &&Other) : Allocs(std::move(Other.Allocs)) {}
+
Allocator &operator=(Allocator &&Other) {
Allocs = std::move(Other.Allocs);
return *this;
@@ -153,7 +151,8 @@ private:
}
Expected<int32_t> handleCallIntVoid(JITTargetAddress Addr) {
- typedef int (*IntVoidFnTy)();
+ using IntVoidFnTy = int (*)();
+
IntVoidFnTy Fn =
reinterpret_cast<IntVoidFnTy>(static_cast<uintptr_t>(Addr));
@@ -166,7 +165,7 @@ private:
Expected<int32_t> handleCallMain(JITTargetAddress Addr,
std::vector<std::string> Args) {
- typedef int (*MainFnTy)(int, const char *[]);
+ using MainFnTy = int (*)(int, const char *[]);
MainFnTy Fn = reinterpret_cast<MainFnTy>(static_cast<uintptr_t>(Addr));
int ArgC = Args.size() + 1;
@@ -175,6 +174,12 @@ private:
ArgV[0] = "<jit process>";
for (auto &Arg : Args)
ArgV[Idx++] = Arg.c_str();
+ ArgV[ArgC] = 0;
+ DEBUG(
+ for (int Idx = 0; Idx < ArgC; ++Idx) {
+ llvm::dbgs() << "Arg " << Idx << ": " << ArgV[Idx] << "\n";
+ }
+ );
DEBUG(dbgs() << " Calling " << format("0x%016x", Addr) << "\n");
int Result = Fn(ArgC, ArgV.get());
@@ -184,7 +189,8 @@ private:
}
Error handleCallVoidVoid(JITTargetAddress Addr) {
- typedef void (*VoidVoidFnTy)();
+ using VoidVoidFnTy = void (*)();
+
VoidVoidFnTy Fn =
reinterpret_cast<VoidVoidFnTy>(static_cast<uintptr_t>(Addr));
@@ -420,11 +426,11 @@ private:
SymbolLookupFtor SymbolLookup;
EHFrameRegistrationFtor EHFramesRegister, EHFramesDeregister;
std::map<ResourceIdMgr::ResourceId, Allocator> Allocators;
- typedef std::vector<typename TargetT::IndirectStubsInfo> ISBlockOwnerList;
+ using ISBlockOwnerList = std::vector<typename TargetT::IndirectStubsInfo>;
std::map<ResourceIdMgr::ResourceId, ISBlockOwnerList> IndirectStubsOwners;
sys::OwningMemoryBlock ResolverBlock;
std::vector<sys::OwningMemoryBlock> TrampolineBlocks;
- bool TerminateFlag;
+ bool TerminateFlag = false;
};
} // end namespace remote
@@ -433,4 +439,4 @@ private:
#undef DEBUG_TYPE
-#endif
+#endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETSERVER_H
diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
index aabb44eef99d..66ad36be01c8 100644
--- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
+++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h
@@ -1,4 +1,4 @@
-//===-- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking --*- C++ -*-===//
+//===- RTDyldObjectLinkingLayer.h - RTDyld-based jit linking ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -17,10 +17,8 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
-#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Error.h"
#include <algorithm>
@@ -36,20 +34,26 @@ namespace llvm {
namespace orc {
class RTDyldObjectLinkingLayerBase {
+public:
+
+ using ObjectPtr =
+ std::shared_ptr<object::OwningBinary<object::ObjectFile>>;
+
protected:
+
/// @brief Holds a set of objects to be allocated/linked as a unit in the JIT.
///
/// An instance of this class will be created for each set of objects added
- /// via JITObjectLayer::addObjectSet. Deleting the instance (via
- /// removeObjectSet) frees its memory, removing all symbol definitions that
+ /// via JITObjectLayer::addObject. Deleting the instance (via
+ /// removeObject) frees its memory, removing all symbol definitions that
/// had been provided by this instance. Higher level layers are responsible
/// for taking any action required to handle the missing symbols.
- class LinkedObjectSet {
+ class LinkedObject {
public:
- LinkedObjectSet() = default;
- LinkedObjectSet(const LinkedObjectSet&) = delete;
- void operator=(const LinkedObjectSet&) = delete;
- virtual ~LinkedObjectSet() = default;
+ LinkedObject() = default;
+ LinkedObject(const LinkedObject&) = delete;
+ void operator=(const LinkedObject&) = delete;
+ virtual ~LinkedObject() = default;
virtual void finalize() = 0;
@@ -76,19 +80,11 @@ protected:
bool Finalized = false;
};
- typedef std::list<std::unique_ptr<LinkedObjectSet>> LinkedObjectSetListT;
+ using LinkedObjectListT = std::list<std::unique_ptr<LinkedObject>>;
public:
/// @brief Handle to a set of loaded objects.
- typedef LinkedObjectSetListT::iterator ObjSetHandleT;
-};
-
-/// @brief Default (no-op) action to perform when loading objects.
-class DoNothingOnNotifyLoaded {
-public:
- template <typename ObjSetT, typename LoadResult>
- void operator()(RTDyldObjectLinkingLayerBase::ObjSetHandleT, const ObjSetT &,
- const LoadResult &) {}
+ using ObjHandleT = LinkedObjectListT::iterator;
};
/// @brief Bare bones object linking layer.
@@ -97,46 +93,54 @@ public:
/// object files to be loaded into memory, linked, and the addresses of their
/// symbols queried. All objects added to this layer can see each other's
/// symbols.
-template <typename NotifyLoadedFtor = DoNothingOnNotifyLoaded>
class RTDyldObjectLinkingLayer : public RTDyldObjectLinkingLayerBase {
public:
+
+ using RTDyldObjectLinkingLayerBase::ObjectPtr;
+
+ /// @brief Functor for receiving object-loaded notifications.
+ using NotifyLoadedFtor = std::function<void(ObjHandleT, const ObjectPtr &Obj,
+ const LoadedObjectInfo &)>;
+
/// @brief Functor for receiving finalization notifications.
- typedef std::function<void(ObjSetHandleT)> NotifyFinalizedFtor;
+ using NotifyFinalizedFtor = std::function<void(ObjHandleT)>;
private:
- template <typename ObjSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT, typename FinalizerFtor>
- class ConcreteLinkedObjectSet : public LinkedObjectSet {
+
+
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT,
+ typename FinalizerFtor>
+ class ConcreteLinkedObject : public LinkedObject {
public:
- ConcreteLinkedObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver,
- FinalizerFtor Finalizer,
- bool ProcessAllSections)
+ ConcreteLinkedObject(ObjectPtr Obj, MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver,
+ FinalizerFtor Finalizer,
+ bool ProcessAllSections)
: MemMgr(std::move(MemMgr)),
- PFC(llvm::make_unique<PreFinalizeContents>(std::move(Objects),
+ PFC(llvm::make_unique<PreFinalizeContents>(std::move(Obj),
std::move(Resolver),
std::move(Finalizer),
ProcessAllSections)) {
- buildInitialSymbolTable(PFC->Objects);
+ buildInitialSymbolTable(PFC->Obj);
}
- ~ConcreteLinkedObjectSet() override {
+ ~ConcreteLinkedObject() override {
MemMgr->deregisterEHFrames();
}
-
- void setHandle(ObjSetHandleT H) {
+
+ void setHandle(ObjHandleT H) {
PFC->Handle = H;
}
void finalize() override {
- assert(PFC && "mapSectionAddress called on finalized LinkedObjectSet");
+ assert(PFC && "mapSectionAddress called on finalized LinkedObject");
RuntimeDyld RTDyld(*MemMgr, *PFC->Resolver);
RTDyld.setProcessAllSections(PFC->ProcessAllSections);
PFC->RTDyld = &RTDyld;
this->Finalized = true;
- PFC->Finalizer(PFC->Handle, RTDyld, std::move(PFC->Objects),
+ PFC->Finalizer(PFC->Handle, RTDyld, std::move(PFC->Obj),
[&]() {
this->updateSymbolTable(RTDyld);
});
@@ -158,27 +162,27 @@ private:
void mapSectionAddress(const void *LocalAddress,
JITTargetAddress TargetAddr) const override {
- assert(PFC && "mapSectionAddress called on finalized LinkedObjectSet");
- assert(PFC->RTDyld && "mapSectionAddress called on raw LinkedObjectSet");
+ assert(PFC && "mapSectionAddress called on finalized LinkedObject");
+ assert(PFC->RTDyld && "mapSectionAddress called on raw LinkedObject");
PFC->RTDyld->mapSectionAddress(LocalAddress, TargetAddr);
}
private:
- void buildInitialSymbolTable(const ObjSetT &Objects) {
- for (const auto &Obj : Objects)
- for (auto &Symbol : getObject(*Obj).symbols()) {
- if (Symbol.getFlags() & object::SymbolRef::SF_Undefined)
- continue;
- Expected<StringRef> SymbolName = Symbol.getName();
- // FIXME: Raise an error for bad symbols.
- if (!SymbolName) {
- consumeError(SymbolName.takeError());
- continue;
- }
- auto Flags = JITSymbolFlags::fromObjectSymbol(Symbol);
- SymbolTable.insert(
- std::make_pair(*SymbolName, JITEvaluatedSymbol(0, Flags)));
+
+ void buildInitialSymbolTable(const ObjectPtr &Obj) {
+ for (auto &Symbol : Obj->getBinary()->symbols()) {
+ if (Symbol.getFlags() & object::SymbolRef::SF_Undefined)
+ continue;
+ Expected<StringRef> SymbolName = Symbol.getName();
+ // FIXME: Raise an error for bad symbols.
+ if (!SymbolName) {
+ consumeError(SymbolName.takeError());
+ continue;
}
+ auto Flags = JITSymbolFlags::fromObjectSymbol(Symbol);
+ SymbolTable.insert(
+ std::make_pair(*SymbolName, JITEvaluatedSymbol(0, Flags)));
+ }
}
void updateSymbolTable(const RuntimeDyld &RTDyld) {
@@ -189,17 +193,17 @@ private:
// Contains the information needed prior to finalization: the object files,
// memory manager, resolver, and flags needed for RuntimeDyld.
struct PreFinalizeContents {
- PreFinalizeContents(ObjSetT Objects, SymbolResolverPtrT Resolver,
+ PreFinalizeContents(ObjectPtr Obj, SymbolResolverPtrT Resolver,
FinalizerFtor Finalizer, bool ProcessAllSections)
- : Objects(std::move(Objects)), Resolver(std::move(Resolver)),
+ : Obj(std::move(Obj)), Resolver(std::move(Resolver)),
Finalizer(std::move(Finalizer)),
ProcessAllSections(ProcessAllSections) {}
- ObjSetT Objects;
+ ObjectPtr Obj;
SymbolResolverPtrT Resolver;
FinalizerFtor Finalizer;
bool ProcessAllSections;
- ObjSetHandleT Handle;
+ ObjHandleT Handle;
RuntimeDyld *RTDyld;
};
@@ -207,27 +211,22 @@ private:
std::unique_ptr<PreFinalizeContents> PFC;
};
- template <typename ObjSetT, typename MemoryManagerPtrT,
- typename SymbolResolverPtrT, typename FinalizerFtor>
+ template <typename MemoryManagerPtrT, typename SymbolResolverPtrT,
+ typename FinalizerFtor>
std::unique_ptr<
- ConcreteLinkedObjectSet<ObjSetT, MemoryManagerPtrT,
- SymbolResolverPtrT, FinalizerFtor>>
- createLinkedObjectSet(ObjSetT Objects, MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver,
- FinalizerFtor Finalizer,
- bool ProcessAllSections) {
- typedef ConcreteLinkedObjectSet<ObjSetT, MemoryManagerPtrT,
- SymbolResolverPtrT, FinalizerFtor> LOS;
- return llvm::make_unique<LOS>(std::move(Objects), std::move(MemMgr),
+ ConcreteLinkedObject<MemoryManagerPtrT, SymbolResolverPtrT, FinalizerFtor>>
+ createLinkedObject(ObjectPtr Obj, MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver,
+ FinalizerFtor Finalizer,
+ bool ProcessAllSections) {
+ using LOS = ConcreteLinkedObject<MemoryManagerPtrT, SymbolResolverPtrT,
+ FinalizerFtor>;
+ return llvm::make_unique<LOS>(std::move(Obj), std::move(MemMgr),
std::move(Resolver), std::move(Finalizer),
ProcessAllSections);
}
public:
- /// @brief LoadedObjectInfo list. Contains a list of owning pointers to
- /// RuntimeDyld::LoadedObjectInfo instances.
- typedef std::vector<std::unique_ptr<RuntimeDyld::LoadedObjectInfo>>
- LoadedObjInfoList;
/// @brief Construct an ObjectLinkingLayer with the given NotifyLoaded,
/// and NotifyFinalized functors.
@@ -235,8 +234,7 @@ public:
NotifyLoadedFtor NotifyLoaded = NotifyLoadedFtor(),
NotifyFinalizedFtor NotifyFinalized = NotifyFinalizedFtor())
: NotifyLoaded(std::move(NotifyLoaded)),
- NotifyFinalized(std::move(NotifyFinalized)),
- ProcessAllSections(false) {}
+ NotifyFinalized(std::move(NotifyFinalized)) {}
/// @brief Set the 'ProcessAllSections' flag.
///
@@ -253,23 +251,22 @@ public:
///
/// @return A handle that can be used to refer to the loaded objects (for
/// symbol searching, finalization, freeing memory, etc.).
- template <typename ObjSetT,
- typename MemoryManagerPtrT,
+ template <typename MemoryManagerPtrT,
typename SymbolResolverPtrT>
- ObjSetHandleT addObjectSet(ObjSetT Objects,
- MemoryManagerPtrT MemMgr,
- SymbolResolverPtrT Resolver) {
- auto Finalizer = [&](ObjSetHandleT H, RuntimeDyld &RTDyld,
- const ObjSetT &Objs,
- std::function<void()> LOSHandleLoad) {
- LoadedObjInfoList LoadedObjInfos;
+ ObjHandleT addObject(ObjectPtr Obj,
+ MemoryManagerPtrT MemMgr,
+ SymbolResolverPtrT Resolver) {
- for (auto &Obj : Objs)
- LoadedObjInfos.push_back(RTDyld.loadObject(this->getObject(*Obj)));
+ auto Finalizer = [&](ObjHandleT H, RuntimeDyld &RTDyld,
+ const ObjectPtr &ObjToLoad,
+ std::function<void()> LOSHandleLoad) {
+ std::unique_ptr<RuntimeDyld::LoadedObjectInfo> Info =
+ RTDyld.loadObject(*ObjToLoad->getBinary());
LOSHandleLoad();
- this->NotifyLoaded(H, Objs, LoadedObjInfos);
+ if (this->NotifyLoaded)
+ this->NotifyLoaded(H, ObjToLoad, *Info);
RTDyld.finalizeWithMemoryManagerLocking();
@@ -277,17 +274,15 @@ public:
this->NotifyFinalized(H);
};
- auto LOS =
- createLinkedObjectSet(std::move(Objects), std::move(MemMgr),
- std::move(Resolver), std::move(Finalizer),
- ProcessAllSections);
+ auto LO =
+ createLinkedObject(std::move(Obj), std::move(MemMgr), std::move(Resolver),
+ std::move(Finalizer), ProcessAllSections);
// LOS is an owning-ptr. Keep a non-owning one so that we can set the handle
// below.
- auto *LOSPtr = LOS.get();
+ auto *LOPtr = LO.get();
- ObjSetHandleT Handle = LinkedObjSetList.insert(LinkedObjSetList.end(),
- std::move(LOS));
- LOSPtr->setHandle(Handle);
+ ObjHandleT Handle = LinkedObjList.insert(LinkedObjList.end(), std::move(LO));
+ LOPtr->setHandle(Handle);
return Handle;
}
@@ -300,9 +295,9 @@ public:
/// indirectly) will result in undefined behavior. If dependence tracking is
/// required to detect or resolve such issues it should be added at a higher
/// layer.
- void removeObjectSet(ObjSetHandleT H) {
+ void removeObject(ObjHandleT H) {
// How do we invalidate the symbols in H?
- LinkedObjSetList.erase(H);
+ LinkedObjList.erase(H);
}
/// @brief Search for the given named symbol.
@@ -310,7 +305,7 @@ public:
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
/// @return A handle for the given named symbol, if it exists.
JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly) {
- for (auto I = LinkedObjSetList.begin(), E = LinkedObjSetList.end(); I != E;
+ for (auto I = LinkedObjList.begin(), E = LinkedObjList.end(); I != E;
++I)
if (auto Symbol = findSymbolIn(I, Name, ExportedSymbolsOnly))
return Symbol;
@@ -325,13 +320,13 @@ public:
/// @param ExportedSymbolsOnly If true, search only for exported symbols.
/// @return A handle for the given named symbol, if it is found in the
/// given object set.
- JITSymbol findSymbolIn(ObjSetHandleT H, StringRef Name,
+ JITSymbol findSymbolIn(ObjHandleT H, StringRef Name,
bool ExportedSymbolsOnly) {
return (*H)->getSymbol(Name, ExportedSymbolsOnly);
}
/// @brief Map section addresses for the objects associated with the handle H.
- void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
+ void mapSectionAddress(ObjHandleT H, const void *LocalAddress,
JITTargetAddress TargetAddr) {
(*H)->mapSectionAddress(LocalAddress, TargetAddr);
}
@@ -339,25 +334,16 @@ public:
/// @brief Immediately emit and finalize the object set represented by the
/// given handle.
/// @param H Handle for object set to emit/finalize.
- void emitAndFinalize(ObjSetHandleT H) {
+ void emitAndFinalize(ObjHandleT H) {
(*H)->finalize();
}
private:
- static const object::ObjectFile& getObject(const object::ObjectFile &Obj) {
- return Obj;
- }
-
- template <typename ObjT>
- static const object::ObjectFile&
- getObject(const object::OwningBinary<ObjT> &Obj) {
- return *Obj.getBinary();
- }
- LinkedObjectSetListT LinkedObjSetList;
+ LinkedObjectListT LinkedObjList;
NotifyLoadedFtor NotifyLoaded;
NotifyFinalizedFtor NotifyFinalized;
- bool ProcessAllSections;
+ bool ProcessAllSections = false;
};
} // end namespace orc
diff --git a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h
index 52a546f7c6eb..db810f4ef2e5 100644
--- a/include/llvm/ExecutionEngine/Orc/RawByteChannel.h
+++ b/include/llvm/ExecutionEngine/Orc/RawByteChannel.h
@@ -10,20 +10,14 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
#define LLVM_EXECUTIONENGINE_ORC_RAWBYTECHANNEL_H
-#include "OrcError.h"
-#include "RPCSerialization.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ExecutionEngine/Orc/RPCSerialization.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Error.h"
-#include <cstddef>
#include <cstdint>
#include <mutex>
#include <string>
-#include <tuple>
#include <type_traits>
-#include <vector>
namespace llvm {
namespace orc {
@@ -32,7 +26,7 @@ namespace rpc {
/// Interface for byte-streams to be used with RPC.
class RawByteChannel {
public:
- virtual ~RawByteChannel() {}
+ virtual ~RawByteChannel() = default;
/// Read Size bytes from the stream into *Dst.
virtual Error readBytes(char *Dst, unsigned Size) = 0;
diff --git a/include/llvm/ExecutionEngine/RuntimeDyld.h b/include/llvm/ExecutionEngine/RuntimeDyld.h
index 9470866dc0d6..1925489f7952 100644
--- a/include/llvm/ExecutionEngine/RuntimeDyld.h
+++ b/include/llvm/ExecutionEngine/RuntimeDyld.h
@@ -1,4 +1,4 @@
-//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===//
+//===- RuntimeDyld.h - Run-time dynamic linker for MC-JIT -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -32,7 +32,9 @@
namespace llvm {
namespace object {
- template <typename T> class OwningBinary;
+
+template <typename T> class OwningBinary;
+
} // end namespace object
/// Base class for errors originating in RuntimeDyld, e.g. missing relocation
@@ -51,8 +53,8 @@ private:
std::string ErrMsg;
};
-class RuntimeDyldImpl;
class RuntimeDyldCheckerImpl;
+class RuntimeDyldImpl;
class RuntimeDyld {
friend class RuntimeDyldCheckerImpl;
@@ -68,7 +70,7 @@ public:
friend class RuntimeDyldImpl;
public:
- typedef std::map<object::SectionRef, unsigned> ObjSectionToIDMap;
+ using ObjSectionToIDMap = std::map<object::SectionRef, unsigned>;
LoadedObjectInfo(RuntimeDyldImpl &RTDyld, ObjSectionToIDMap ObjSecToIDMap)
: RTDyld(RTDyld), ObjSecToIDMap(std::move(ObjSecToIDMap)) {}
@@ -186,7 +188,7 @@ public:
/// \brief Construct a RuntimeDyld instance.
RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
RuntimeDyld(const RuntimeDyld &) = delete;
- void operator=(const RuntimeDyld &) = delete;
+ RuntimeDyld &operator=(const RuntimeDyld &) = delete;
~RuntimeDyld();
/// Add the referenced object file to the list of objects to be loaded and
diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h
index 0e8adda82cbe..0cab8bbb8ead 100644
--- a/include/llvm/IR/Attributes.h
+++ b/include/llvm/IR/Attributes.h
@@ -622,7 +622,8 @@ public:
// AttributeList Introspection
//===--------------------------------------------------------------------===//
- typedef const AttributeSet *iterator;
+ using iterator = const AttributeSet *;
+
iterator begin() const;
iterator end() const;
@@ -830,8 +831,8 @@ bool areInlineCompatible(const Function &Caller, const Function &Callee);
/// \brief Merge caller's and callee's attributes.
void mergeAttributesForInlining(Function &Caller, const Function &Callee);
-} // end AttributeFuncs namespace
+} // end namespace AttributeFuncs
-} // end llvm namespace
+} // end namespace llvm
#endif // LLVM_IR_ATTRIBUTES_H
diff --git a/include/llvm/IR/Attributes.td b/include/llvm/IR/Attributes.td
index 75867a6e5833..616387816bf8 100644
--- a/include/llvm/IR/Attributes.td
+++ b/include/llvm/IR/Attributes.td
@@ -214,3 +214,5 @@ def : MergeRule<"setAND<UnsafeFPMathAttr>">;
def : MergeRule<"setOR<NoImplicitFloatAttr>">;
def : MergeRule<"setOR<NoJumpTablesAttr>">;
def : MergeRule<"adjustCallerSSPLevel">;
+def : MergeRule<"adjustCallerStackProbes">;
+def : MergeRule<"adjustCallerStackProbeSize">;
diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h
index 23f838b640e0..7a35afcbafc3 100644
--- a/include/llvm/IR/BasicBlock.h
+++ b/include/llvm/IR/BasicBlock.h
@@ -1,4 +1,4 @@
-//===-- llvm/BasicBlock.h - Represent a basic block in the VM ---*- C++ -*-===//
+//===- llvm/BasicBlock.h - Represent a basic block in the VM ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,13 +18,17 @@
#include "llvm/ADT/Twine.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/CBindingWrapping.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
#include <cstddef>
+#include <iterator>
namespace llvm {
@@ -294,9 +298,9 @@ public:
return *this;
}
};
- typedef phi_iterator_impl<> phi_iterator;
- typedef phi_iterator_impl<const PHINode, BasicBlock::const_iterator>
- const_phi_iterator;
+ using phi_iterator = phi_iterator_impl<>;
+ using const_phi_iterator =
+ phi_iterator_impl<const PHINode, BasicBlock::const_iterator>;
/// Returns a range that iterates over the phis in the basic block.
///
@@ -391,6 +395,9 @@ public:
static_cast<const BasicBlock *>(this)->getLandingPadInst());
}
+ /// \brief Return true if it is legal to hoist instructions into this block.
+ bool isLegalToHoistInto() const;
+
private:
/// \brief Increment the internal refcount of the number of BlockAddresses
/// referencing this BasicBlock by \p Amt.
diff --git a/include/llvm/IR/ConstantRange.h b/include/llvm/IR/ConstantRange.h
index 6a50a8801f86..ff6495e7f075 100644
--- a/include/llvm/IR/ConstantRange.h
+++ b/include/llvm/IR/ConstantRange.h
@@ -34,11 +34,14 @@
#include "llvm/ADT/APInt.h"
#include "llvm/IR/InstrTypes.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/Support/Compiler.h"
+#include <cstdint>
namespace llvm {
class MDNode;
+class raw_ostream;
/// This class represents a range of values.
class LLVM_NODISCARD ConstantRange {
@@ -330,6 +333,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const ConstantRange &CR) {
/// E.g. if RangeMD is !{i32 0, i32 10, i32 15, i32 20} then return [0, 20).
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD);
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_CONSTANTRANGE_H
diff --git a/include/llvm/IR/DerivedUser.h b/include/llvm/IR/DerivedUser.h
index 4d681e0db611..67c483d3c497 100644
--- a/include/llvm/IR/DerivedUser.h
+++ b/include/llvm/IR/DerivedUser.h
@@ -1,4 +1,4 @@
-//===-- DerivedUser.h - Base for non-IR Users -------------------*- C++ -*-===//
+//===- DerivedUser.h - Base for non-IR Users --------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,6 +14,9 @@
namespace llvm {
+class Type;
+class Use;
+
/// Extension point for the Value hierarchy. All classes outside of lib/IR
/// that wish to inherit from User should instead inherit from DerivedUser
/// instead. Inheriting from this class is discouraged.
@@ -24,10 +27,11 @@ namespace llvm {
/// its use/def list machinery.
class DerivedUser : public User {
protected:
- typedef void (*DeleteValueTy)(DerivedUser *);
+ using DeleteValueTy = void (*)(DerivedUser *);
private:
- friend Value;
+ friend class Value;
+
DeleteValueTy DeleteValue;
public:
@@ -36,6 +40,6 @@ public:
: User(Ty, VK, U, NumOps), DeleteValue(DeleteValue) {}
};
-} // namespace llvm
+} // end namespace llvm
#endif // LLVM_IR_DERIVEDUSER_H
diff --git a/include/llvm/IR/InstrTypes.h b/include/llvm/IR/InstrTypes.h
index b3c6644c7e81..76524b412456 100644
--- a/include/llvm/IR/InstrTypes.h
+++ b/include/llvm/IR/InstrTypes.h
@@ -322,14 +322,14 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryInstruction, Value)
//===----------------------------------------------------------------------===//
class BinaryOperator : public Instruction {
+ void AssertOK();
+
protected:
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
const Twine &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty,
const Twine &Name, BasicBlock *InsertAtEnd);
- void init(BinaryOps iType);
-
// Note: Instruction needs to be a friend here to call cloneImpl.
friend class Instruction;
diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h
index 00c431834e31..d8db29e15886 100644
--- a/include/llvm/IR/Instruction.h
+++ b/include/llvm/IR/Instruction.h
@@ -152,9 +152,14 @@ public:
return getOpcode() == AShr;
}
+ /// Determine if the Opcode is and/or/xor.
+ static inline bool isBitwiseLogicOp(unsigned Opcode) {
+ return Opcode == And || Opcode == Or || Opcode == Xor;
+ }
+
/// Return true if this is and/or/xor.
inline bool isBitwiseLogicOp() const {
- return getOpcode() == And || getOpcode() == Or || getOpcode() == Xor;
+ return isBitwiseLogicOp(getOpcode());
}
/// Determine if the OpCode is one of the CastInst instructions.
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h
index b3032f54aa42..e1620b3e7df5 100644
--- a/include/llvm/IR/Instructions.h
+++ b/include/llvm/IR/Instructions.h
@@ -1243,6 +1243,16 @@ public:
/// vectors of floating point values. The operands must be identical types.
/// Represents a floating point comparison operator.
class FCmpInst: public CmpInst {
+ void AssertOK() {
+ assert(getPredicate() <= FCmpInst::LAST_FCMP_PREDICATE &&
+ "Invalid FCmp predicate value");
+ assert(getOperand(0)->getType() == getOperand(1)->getType() &&
+ "Both operands to FCmp instruction are not of the same type!");
+ // Check that the operands are the right type
+ assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
+ "Invalid operand types for FCmp instruction");
+ }
+
protected:
// Note: Instruction needs to be a friend here to call cloneImpl.
friend class Instruction;
@@ -1261,13 +1271,7 @@ public:
) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) {
- assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
- "Invalid FCmp predicate value");
- assert(getOperand(0)->getType() == getOperand(1)->getType() &&
- "Both operands to FCmp instruction are not of the same type!");
- // Check that the operands are the right type
- assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
- "Invalid operand types for FCmp instruction");
+ AssertOK();
}
/// Constructor with insert-at-end semantics.
@@ -1280,13 +1284,7 @@ public:
) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) {
- assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
- "Invalid FCmp predicate value");
- assert(getOperand(0)->getType() == getOperand(1)->getType() &&
- "Both operands to FCmp instruction are not of the same type!");
- // Check that the operands are the right type
- assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
- "Invalid operand types for FCmp instruction");
+ AssertOK();
}
/// Constructor with no-insertion semantics
@@ -1297,13 +1295,7 @@ public:
const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr) {
- assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
- "Invalid FCmp predicate value");
- assert(getOperand(0)->getType() == getOperand(1)->getType() &&
- "Both operands to FCmp instruction are not of the same type!");
- // Check that the operands are the right type
- assert(getOperand(0)->getType()->isFPOrFPVectorTy() &&
- "Invalid operand types for FCmp instruction");
+ AssertOK();
}
/// @returns true if the predicate of this instruction is EQ or NE.
diff --git a/include/llvm/IR/IntrinsicsAMDGPU.td b/include/llvm/IR/IntrinsicsAMDGPU.td
index 8017223c4ab0..4e0529a32d29 100644
--- a/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -475,6 +475,33 @@ class AMDGPUBufferStore : Intrinsic <
def int_amdgcn_buffer_store_format : AMDGPUBufferStore;
def int_amdgcn_buffer_store : AMDGPUBufferStore;
+def int_amdgcn_tbuffer_load : Intrinsic <
+ [llvm_any_ty], // overloaded for types f32/i32, v2f32/v2i32, v4f32/v4i32
+ [llvm_v4i32_ty, // rsrc(SGPR)
+ llvm_i32_ty, // vindex(VGPR)
+ llvm_i32_ty, // voffset(VGPR)
+ llvm_i32_ty, // soffset(SGPR)
+ llvm_i32_ty, // offset(imm)
+ llvm_i32_ty, // dfmt(imm)
+ llvm_i32_ty, // nfmt(imm)
+ llvm_i1_ty, // glc(imm)
+ llvm_i1_ty], // slc(imm)
+ []>;
+
+def int_amdgcn_tbuffer_store : Intrinsic <
+ [],
+ [llvm_any_ty, // vdata(VGPR), overloaded for types f32/i32, v2f32/v2i32, v4f32/v4i32
+ llvm_v4i32_ty, // rsrc(SGPR)
+ llvm_i32_ty, // vindex(VGPR)
+ llvm_i32_ty, // voffset(VGPR)
+ llvm_i32_ty, // soffset(SGPR)
+ llvm_i32_ty, // offset(imm)
+ llvm_i32_ty, // dfmt(imm)
+ llvm_i32_ty, // nfmt(imm)
+ llvm_i1_ty, // glc(imm)
+ llvm_i1_ty], // slc(imm)
+ []>;
+
class AMDGPUBufferAtomic : Intrinsic <
[llvm_i32_ty],
[llvm_i32_ty, // vdata(VGPR)
diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td
index 1c466e73eb1b..80c528768dc7 100644
--- a/include/llvm/IR/IntrinsicsX86.td
+++ b/include/llvm/IR/IntrinsicsX86.td
@@ -5420,86 +5420,6 @@ let TargetPrefix = "x86" in {
def int_x86_avx512_vcomi_ss : GCCBuiltin<"__builtin_ia32_vcomiss">,
Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
llvm_v4f32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
-
- def int_x86_avx512_mask_cmp_b_512:
- Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i32_ty,
- llvm_i64_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_w_512:
- Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty,
- llvm_i32_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_d_512:
- Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem ]>;
- def int_x86_avx512_mask_cmp_q_512:
- Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
-
- def int_x86_avx512_mask_ucmp_b_512:
- Intrinsic<[llvm_i64_ty], [llvm_v64i8_ty, llvm_v64i8_ty, llvm_i32_ty,
- llvm_i64_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_w_512:
- Intrinsic<[llvm_i32_ty], [llvm_v32i16_ty, llvm_v32i16_ty, llvm_i32_ty,
- llvm_i32_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_d_512:
- Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_q_512:
- Intrinsic<[llvm_i8_ty], [llvm_v8i64_ty, llvm_v8i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
-
- // 256-bit
- def int_x86_avx512_mask_cmp_b_256:
- Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i32_ty,
- llvm_i32_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_w_256:
- Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_d_256:
- Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_q_256:
- Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
-
- def int_x86_avx512_mask_ucmp_b_256:
- Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty, llvm_v32i8_ty, llvm_i32_ty,
- llvm_i32_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_w_256:
- Intrinsic<[llvm_i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_d_256:
- Intrinsic<[llvm_i8_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_q_256:
- Intrinsic<[llvm_i8_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
-
- // 128-bit
- def int_x86_avx512_mask_cmp_b_128:
- Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_w_128:
- Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_d_128:
- Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_cmp_q_128:
- Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
-
- def int_x86_avx512_mask_ucmp_b_128:
- Intrinsic<[llvm_i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty,
- llvm_i16_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_w_128:
- Intrinsic<[llvm_i8_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_d_128:
- Intrinsic<[llvm_i8_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
- def int_x86_avx512_mask_ucmp_q_128:
- Intrinsic<[llvm_i8_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty,
- llvm_i8_ty], [IntrNoMem]>;
}
// Compress, Expand
diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h
index d538c2595393..80ed44be43eb 100644
--- a/include/llvm/IR/Metadata.h
+++ b/include/llvm/IR/Metadata.h
@@ -45,6 +45,8 @@ namespace llvm {
class Module;
class ModuleSlotTracker;
+class raw_ostream;
+class Type;
enum LLVMConstants : uint32_t {
DEBUG_METADATA_VERSION = 3 // Current debug info version number.
@@ -67,8 +69,8 @@ protected:
unsigned char Storage;
// TODO: expose remaining bits to subclasses.
- unsigned short SubclassData16;
- unsigned SubclassData32;
+ unsigned short SubclassData16 = 0;
+ unsigned SubclassData32 = 0;
public:
enum MetadataKind {
@@ -78,7 +80,7 @@ public:
protected:
Metadata(unsigned ID, StorageType Storage)
- : SubclassID(ID), Storage(Storage), SubclassData16(0), SubclassData32(0) {
+ : SubclassID(ID), Storage(Storage) {
static_assert(sizeof(*this) == 8, "Metadata fields poorly packed");
}
@@ -183,6 +185,7 @@ public:
static MetadataAsValue *get(LLVMContext &Context, Metadata *MD);
static MetadataAsValue *getIfExists(LLVMContext &Context, Metadata *MD);
+
Metadata *getMetadata() const { return MD; }
static bool classof(const Value *V) {
@@ -257,7 +260,7 @@ public:
/// \brief Check whether metadata is replaceable.
static bool isReplaceable(const Metadata &MD);
- typedef PointerUnion<MetadataAsValue *, Metadata *> OwnerTy;
+ using OwnerTy = PointerUnion<MetadataAsValue *, Metadata *>;
private:
/// \brief Track a reference to metadata for an owner.
@@ -275,7 +278,7 @@ class ReplaceableMetadataImpl {
friend class MetadataTracking;
public:
- typedef MetadataTracking::OwnerTy OwnerTy;
+ using OwnerTy = MetadataTracking::OwnerTy;
private:
LLVMContext &Context;
@@ -352,17 +355,21 @@ protected:
public:
static ValueAsMetadata *get(Value *V);
+
static ConstantAsMetadata *getConstant(Value *C) {
return cast<ConstantAsMetadata>(get(C));
}
+
static LocalAsMetadata *getLocal(Value *Local) {
return cast<LocalAsMetadata>(get(Local));
}
static ValueAsMetadata *getIfExists(Value *V);
+
static ConstantAsMetadata *getConstantIfExists(Value *C) {
return cast_or_null<ConstantAsMetadata>(getIfExists(C));
}
+
static LocalAsMetadata *getLocalIfExists(Value *Local) {
return cast_or_null<LocalAsMetadata>(getIfExists(Local));
}
@@ -491,8 +498,8 @@ namespace detail {
template <class T> T &make();
template <class T, class Result> struct HasDereference {
- typedef char Yes[1];
- typedef char No[2];
+ using Yes = char[1];
+ using No = char[2];
template <size_t N> struct SFINAE {};
template <class U, class V>
@@ -613,7 +620,7 @@ public:
unsigned getLength() const { return (unsigned)getString().size(); }
- typedef StringRef::iterator iterator;
+ using iterator = StringRef::iterator;
/// \brief Pointer to the first byte of the string.
iterator begin() const { return getString().begin(); }
@@ -730,12 +737,14 @@ private:
};
template <> struct simplify_type<MDOperand> {
- typedef Metadata *SimpleType;
+ using SimpleType = Metadata *;
+
static SimpleType getSimplifiedValue(MDOperand &MD) { return MD.get(); }
};
template <> struct simplify_type<const MDOperand> {
- typedef Metadata *SimpleType;
+ using SimpleType = Metadata *;
+
static SimpleType getSimplifiedValue(const MDOperand &MD) { return MD.get(); }
};
@@ -817,7 +826,7 @@ struct TempMDNodeDeleter {
};
#define HANDLE_MDNODE_LEAF(CLASS) \
- typedef std::unique_ptr<CLASS, TempMDNodeDeleter> Temp##CLASS;
+ using Temp##CLASS = std::unique_ptr<CLASS, TempMDNodeDeleter>;
#define HANDLE_MDNODE_BRANCH(CLASS) HANDLE_MDNODE_LEAF(CLASS)
#include "llvm/IR/Metadata.def"
@@ -847,6 +856,10 @@ class MDNode : public Metadata {
ContextAndReplaceableUses Context;
protected:
+ MDNode(LLVMContext &Context, unsigned ID, StorageType Storage,
+ ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None);
+ ~MDNode() = default;
+
void *operator new(size_t Size, unsigned NumOps);
void operator delete(void *Mem);
@@ -860,16 +873,13 @@ protected:
llvm_unreachable("Constructor throws?");
}
- MDNode(LLVMContext &Context, unsigned ID, StorageType Storage,
- ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None);
- ~MDNode() = default;
-
void dropAllReferences();
MDOperand *mutable_begin() { return mutable_end() - NumOperands; }
MDOperand *mutable_end() { return reinterpret_cast<MDOperand *>(this); }
- typedef iterator_range<MDOperand *> mutable_op_range;
+ using mutable_op_range = iterator_range<MDOperand *>;
+
mutable_op_range mutable_operands() {
return mutable_op_range(mutable_begin(), mutable_end());
}
@@ -1028,8 +1038,8 @@ private:
static void dispatchResetHash(NodeTy *, std::false_type) {}
public:
- typedef const MDOperand *op_iterator;
- typedef iterator_range<op_iterator> op_range;
+ using op_iterator = const MDOperand *;
+ using op_range = iterator_range<op_iterator>;
op_iterator op_begin() const {
return const_cast<MDNode *>(this)->mutable_begin();
@@ -1227,13 +1237,14 @@ public:
T *operator[](unsigned I) const { return cast_or_null<T>(N->getOperand(I)); }
// FIXME: Fix callers and remove condition on N.
- typedef TypedMDOperandIterator<T> iterator;
+ using iterator = TypedMDOperandIterator<T>;
+
iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
};
#define HANDLE_METADATA(CLASS) \
- typedef MDTupleTypedArrayWrapper<CLASS> CLASS##Array;
+ using CLASS##Array = MDTupleTypedArrayWrapper<CLASS>;
#include "llvm/IR/Metadata.def"
/// Placeholder metadata for operands of distinct MDNodes.
@@ -1304,12 +1315,12 @@ class NamedMDNode : public ilist_node<NamedMDNode> {
template<class T1, class T2>
class op_iterator_impl :
public std::iterator<std::bidirectional_iterator_tag, T2> {
+ friend class NamedMDNode;
+
const NamedMDNode *Node = nullptr;
unsigned Idx = 0;
- op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) { }
-
- friend class NamedMDNode;
+ op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) {}
public:
op_iterator_impl() = default;
@@ -1371,11 +1382,13 @@ public:
// ---------------------------------------------------------------------------
// Operand Iterator interface...
//
- typedef op_iterator_impl<MDNode *, MDNode> op_iterator;
+ using op_iterator = op_iterator_impl<MDNode *, MDNode>;
+
op_iterator op_begin() { return op_iterator(this, 0); }
op_iterator op_end() { return op_iterator(this, getNumOperands()); }
- typedef op_iterator_impl<const MDNode *, MDNode> const_op_iterator;
+ using const_op_iterator = op_iterator_impl<const MDNode *, MDNode>;
+
const_op_iterator op_begin() const { return const_op_iterator(this, 0); }
const_op_iterator op_end() const { return const_op_iterator(this, getNumOperands()); }
diff --git a/include/llvm/IR/ModuleSummaryIndexYAML.h b/include/llvm/IR/ModuleSummaryIndexYAML.h
index 8950c527cc18..5d7b8b997d37 100644
--- a/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -188,7 +188,7 @@ template <> struct MappingTraits<FunctionSummaryYaml> {
LLVM_YAML_IS_STRING_MAP(TypeIdSummary)
LLVM_YAML_IS_SEQUENCE_VECTOR(FunctionSummaryYaml)
-LLVM_YAML_IS_SEQUENCE_VECTOR(std::string)
+LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(std::string)
namespace llvm {
namespace yaml {
diff --git a/include/llvm/IR/Operator.h b/include/llvm/IR/Operator.h
index 6eb5998478c6..c7f4697e93e7 100644
--- a/include/llvm/IR/Operator.h
+++ b/include/llvm/IR/Operator.h
@@ -328,8 +328,15 @@ public:
return I->getType()->isFPOrFPVectorTy() ||
I->getOpcode() == Instruction::FCmp;
}
+
+ static inline bool classof(const ConstantExpr *CE) {
+ return CE->getType()->isFPOrFPVectorTy() ||
+ CE->getOpcode() == Instruction::FCmp;
+ }
+
static inline bool classof(const Value *V) {
- return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ return (isa<Instruction>(V) && classof(cast<Instruction>(V))) ||
+ (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V)));
}
};
diff --git a/include/llvm/IR/PatternMatch.h b/include/llvm/IR/PatternMatch.h
index 015a17e8e7ca..9e9c8ac75d2a 100644
--- a/include/llvm/IR/PatternMatch.h
+++ b/include/llvm/IR/PatternMatch.h
@@ -167,10 +167,8 @@ inline match_combine_or<match_zero, match_neg_zero> m_AnyZero() {
struct match_nan {
template <typename ITy> bool match(ITy *V) {
- if (const auto *C = dyn_cast<ConstantFP>(V)) {
- const APFloat &APF = C->getValueAPF();
- return APF.isNaN();
- }
+ if (const auto *C = dyn_cast<ConstantFP>(V))
+ return C->isNaN();
return false;
}
};
@@ -419,7 +417,8 @@ inline bind_const_intval_ty m_ConstantInt(uint64_t &V) { return V; }
//===----------------------------------------------------------------------===//
// Matcher for any binary operator.
//
-template <typename LHS_t, typename RHS_t> struct AnyBinaryOp_match {
+template <typename LHS_t, typename RHS_t, bool Commutable = false>
+struct AnyBinaryOp_match {
LHS_t L;
RHS_t R;
@@ -427,7 +426,9 @@ template <typename LHS_t, typename RHS_t> struct AnyBinaryOp_match {
template <typename OpTy> bool match(OpTy *V) {
if (auto *I = dyn_cast<BinaryOperator>(V))
- return L.match(I->getOperand(0)) && R.match(I->getOperand(1));
+ return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
+ (Commutable && R.match(I->getOperand(0)) &&
+ L.match(I->getOperand(1)));
return false;
}
};
@@ -441,7 +442,8 @@ inline AnyBinaryOp_match<LHS, RHS> m_BinOp(const LHS &L, const RHS &R) {
// Matchers for specific binary operators.
//
-template <typename LHS_t, typename RHS_t, unsigned Opcode>
+template <typename LHS_t, typename RHS_t, unsigned Opcode,
+ bool Commutable = false>
struct BinaryOp_match {
LHS_t L;
RHS_t R;
@@ -451,11 +453,15 @@ struct BinaryOp_match {
template <typename OpTy> bool match(OpTy *V) {
if (V->getValueID() == Value::InstructionVal + Opcode) {
auto *I = cast<BinaryOperator>(V);
- return L.match(I->getOperand(0)) && R.match(I->getOperand(1));
+ return (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
+ (Commutable && R.match(I->getOperand(0)) &&
+ L.match(I->getOperand(1)));
}
if (auto *CE = dyn_cast<ConstantExpr>(V))
- return CE->getOpcode() == Opcode && L.match(CE->getOperand(0)) &&
- R.match(CE->getOperand(1));
+ return CE->getOpcode() == Opcode &&
+ ((L.match(CE->getOperand(0)) && R.match(CE->getOperand(1))) ||
+ (Commutable && R.match(CE->getOperand(0)) &&
+ L.match(CE->getOperand(1))));
return false;
}
};
@@ -660,47 +666,87 @@ m_NUWShl(const LHS &L, const RHS &R) {
}
//===----------------------------------------------------------------------===//
-// Class that matches two different binary ops.
+// Class that matches a group of binary opcodes.
//
-template <typename LHS_t, typename RHS_t, unsigned Opc1, unsigned Opc2>
-struct BinOp2_match {
+template <typename LHS_t, typename RHS_t, typename Predicate>
+struct BinOpPred_match : Predicate {
LHS_t L;
RHS_t R;
- BinOp2_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
+ BinOpPred_match(const LHS_t &LHS, const RHS_t &RHS) : L(LHS), R(RHS) {}
template <typename OpTy> bool match(OpTy *V) {
- if (V->getValueID() == Value::InstructionVal + Opc1 ||
- V->getValueID() == Value::InstructionVal + Opc2) {
- auto *I = cast<BinaryOperator>(V);
- return L.match(I->getOperand(0)) && R.match(I->getOperand(1));
- }
+ if (auto *I = dyn_cast<Instruction>(V))
+ return this->isOpType(I->getOpcode()) && L.match(I->getOperand(0)) &&
+ R.match(I->getOperand(1));
if (auto *CE = dyn_cast<ConstantExpr>(V))
- return (CE->getOpcode() == Opc1 || CE->getOpcode() == Opc2) &&
- L.match(CE->getOperand(0)) && R.match(CE->getOperand(1));
+ return this->isOpType(CE->getOpcode()) && L.match(CE->getOperand(0)) &&
+ R.match(CE->getOperand(1));
return false;
}
};
-/// \brief Matches LShr or AShr.
+struct is_shift_op {
+ bool isOpType(unsigned Opcode) { return Instruction::isShift(Opcode); }
+};
+
+struct is_right_shift_op {
+ bool isOpType(unsigned Opcode) {
+ return Opcode == Instruction::LShr || Opcode == Instruction::AShr;
+ }
+};
+
+struct is_logical_shift_op {
+ bool isOpType(unsigned Opcode) {
+ return Opcode == Instruction::LShr || Opcode == Instruction::Shl;
+ }
+};
+
+struct is_bitwiselogic_op {
+ bool isOpType(unsigned Opcode) {
+ return Instruction::isBitwiseLogicOp(Opcode);
+ }
+};
+
+struct is_idiv_op {
+ bool isOpType(unsigned Opcode) {
+ return Opcode == Instruction::SDiv || Opcode == Instruction::UDiv;
+ }
+};
+
+/// \brief Matches shift operations.
template <typename LHS, typename RHS>
-inline BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::AShr>
-m_Shr(const LHS &L, const RHS &R) {
- return BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::AShr>(L, R);
+inline BinOpPred_match<LHS, RHS, is_shift_op> m_Shift(const LHS &L,
+ const RHS &R) {
+ return BinOpPred_match<LHS, RHS, is_shift_op>(L, R);
}
-/// \brief Matches LShr or Shl.
+/// \brief Matches logical shift operations.
template <typename LHS, typename RHS>
-inline BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::Shl>
+inline BinOpPred_match<LHS, RHS, is_right_shift_op> m_Shr(const LHS &L,
+ const RHS &R) {
+ return BinOpPred_match<LHS, RHS, is_right_shift_op>(L, R);
+}
+
+/// \brief Matches logical shift operations.
+template <typename LHS, typename RHS>
+inline BinOpPred_match<LHS, RHS, is_logical_shift_op>
m_LogicalShift(const LHS &L, const RHS &R) {
- return BinOp2_match<LHS, RHS, Instruction::LShr, Instruction::Shl>(L, R);
+ return BinOpPred_match<LHS, RHS, is_logical_shift_op>(L, R);
}
-/// \brief Matches UDiv and SDiv.
+/// \brief Matches bitwise logic operations.
template <typename LHS, typename RHS>
-inline BinOp2_match<LHS, RHS, Instruction::SDiv, Instruction::UDiv>
-m_IDiv(const LHS &L, const RHS &R) {
- return BinOp2_match<LHS, RHS, Instruction::SDiv, Instruction::UDiv>(L, R);
+inline BinOpPred_match<LHS, RHS, is_bitwiselogic_op>
+m_BitwiseLogic(const LHS &L, const RHS &R) {
+ return BinOpPred_match<LHS, RHS, is_bitwiselogic_op>(L, R);
+}
+
+/// \brief Matches integer division operations.
+template <typename LHS, typename RHS>
+inline BinOpPred_match<LHS, RHS, is_idiv_op> m_IDiv(const LHS &L,
+ const RHS &R) {
+ return BinOpPred_match<LHS, RHS, is_idiv_op>(L, R);
}
//===----------------------------------------------------------------------===//
@@ -726,7 +772,8 @@ template <typename T> inline Exact_match<T> m_Exact(const T &SubPattern) {
// Matchers for CmpInst classes
//
-template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy>
+template <typename LHS_t, typename RHS_t, typename Class, typename PredicateTy,
+ bool Commutable = false>
struct CmpClass_match {
PredicateTy &Predicate;
LHS_t L;
@@ -737,7 +784,9 @@ struct CmpClass_match {
template <typename OpTy> bool match(OpTy *V) {
if (auto *I = dyn_cast<Class>(V))
- if (L.match(I->getOperand(0)) && R.match(I->getOperand(1))) {
+ if ((L.match(I->getOperand(0)) && R.match(I->getOperand(1))) ||
+ (Commutable && R.match(I->getOperand(0)) &&
+ L.match(I->getOperand(1)))) {
Predicate = I->getPredicate();
return true;
}
@@ -897,10 +946,7 @@ template <typename LHS_t> struct not_match {
private:
bool isAllOnes(Value *V) {
- return (isa<ConstantInt>(V) || isa<ConstantDataVector>(V) ||
- // FIXME: Remove CV.
- isa<ConstantVector>(V)) &&
- cast<Constant>(V)->isAllOnesValue();
+ return isa<Constant>(V) && cast<Constant>(V)->isAllOnesValue();
}
};
@@ -1002,7 +1048,8 @@ inline brc_match<Cond_t> m_Br(const Cond_t &C, BasicBlock *&T, BasicBlock *&F) {
// Matchers for max/min idioms, eg: "select (sgt x, y), x, y" -> smax(x,y).
//
-template <typename CmpInst_t, typename LHS_t, typename RHS_t, typename Pred_t>
+template <typename CmpInst_t, typename LHS_t, typename RHS_t, typename Pred_t,
+ bool Commutable = false>
struct MaxMin_match {
LHS_t L;
RHS_t R;
@@ -1032,7 +1079,8 @@ struct MaxMin_match {
if (!Pred_t::match(Pred))
return false;
// It does! Bind the operands.
- return L.match(LHS) && R.match(RHS);
+ return (L.match(LHS) && R.match(RHS)) ||
+ (Commutable && R.match(LHS) && L.match(RHS));
}
};
@@ -1376,89 +1424,78 @@ template <typename Val_t> inline Signum_match<Val_t> m_Signum(const Val_t &V) {
//
/// \brief Matches a BinaryOperator with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<AnyBinaryOp_match<LHS, RHS>,
- AnyBinaryOp_match<RHS, LHS>>
-m_c_BinOp(const LHS &L, const RHS &R) {
- return m_CombineOr(m_BinOp(L, R), m_BinOp(R, L));
+template <typename LHS, typename RHS>
+inline AnyBinaryOp_match<LHS, RHS, true> m_c_BinOp(const LHS &L, const RHS &R) {
+ return AnyBinaryOp_match<LHS, RHS, true>(L, R);
}
/// \brief Matches an ICmp with a predicate over LHS and RHS in either order.
/// Does not swap the predicate.
-template<typename LHS, typename RHS>
-inline match_combine_or<CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate>,
- CmpClass_match<RHS, LHS, ICmpInst, ICmpInst::Predicate>>
+template <typename LHS, typename RHS>
+inline CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true>
m_c_ICmp(ICmpInst::Predicate &Pred, const LHS &L, const RHS &R) {
- return m_CombineOr(m_ICmp(Pred, L, R), m_ICmp(Pred, R, L));
+ return CmpClass_match<LHS, RHS, ICmpInst, ICmpInst::Predicate, true>(Pred, L,
+ R);
}
/// \brief Matches a Add with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Add>,
- BinaryOp_match<RHS, LHS, Instruction::Add>>
-m_c_Add(const LHS &L, const RHS &R) {
- return m_CombineOr(m_Add(L, R), m_Add(R, L));
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, Instruction::Add, true> m_c_Add(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Add, true>(L, R);
}
/// \brief Matches a Mul with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Mul>,
- BinaryOp_match<RHS, LHS, Instruction::Mul>>
-m_c_Mul(const LHS &L, const RHS &R) {
- return m_CombineOr(m_Mul(L, R), m_Mul(R, L));
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, Instruction::Mul, true> m_c_Mul(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Mul, true>(L, R);
}
/// \brief Matches an And with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::And>,
- BinaryOp_match<RHS, LHS, Instruction::And>>
-m_c_And(const LHS &L, const RHS &R) {
- return m_CombineOr(m_And(L, R), m_And(R, L));
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, Instruction::And, true> m_c_And(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::And, true>(L, R);
}
/// \brief Matches an Or with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Or>,
- BinaryOp_match<RHS, LHS, Instruction::Or>>
-m_c_Or(const LHS &L, const RHS &R) {
- return m_CombineOr(m_Or(L, R), m_Or(R, L));
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, Instruction::Or, true> m_c_Or(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Or, true>(L, R);
}
/// \brief Matches an Xor with LHS and RHS in either order.
-template<typename LHS, typename RHS>
-inline match_combine_or<BinaryOp_match<LHS, RHS, Instruction::Xor>,
- BinaryOp_match<RHS, LHS, Instruction::Xor>>
-m_c_Xor(const LHS &L, const RHS &R) {
- return m_CombineOr(m_Xor(L, R), m_Xor(R, L));
+template <typename LHS, typename RHS>
+inline BinaryOp_match<LHS, RHS, Instruction::Xor, true> m_c_Xor(const LHS &L,
+ const RHS &R) {
+ return BinaryOp_match<LHS, RHS, Instruction::Xor, true>(L, R);
}
/// Matches an SMin with LHS and RHS in either order.
template <typename LHS, typename RHS>
-inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty>,
- MaxMin_match<ICmpInst, RHS, LHS, smin_pred_ty>>
+inline MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true>
m_c_SMin(const LHS &L, const RHS &R) {
- return m_CombineOr(m_SMin(L, R), m_SMin(R, L));
+ return MaxMin_match<ICmpInst, LHS, RHS, smin_pred_ty, true>(L, R);
}
/// Matches an SMax with LHS and RHS in either order.
template <typename LHS, typename RHS>
-inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty>,
- MaxMin_match<ICmpInst, RHS, LHS, smax_pred_ty>>
+inline MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty, true>
m_c_SMax(const LHS &L, const RHS &R) {
- return m_CombineOr(m_SMax(L, R), m_SMax(R, L));
+ return MaxMin_match<ICmpInst, LHS, RHS, smax_pred_ty, true>(L, R);
}
/// Matches a UMin with LHS and RHS in either order.
template <typename LHS, typename RHS>
-inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty>,
- MaxMin_match<ICmpInst, RHS, LHS, umin_pred_ty>>
+inline MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty, true>
m_c_UMin(const LHS &L, const RHS &R) {
- return m_CombineOr(m_UMin(L, R), m_UMin(R, L));
+ return MaxMin_match<ICmpInst, LHS, RHS, umin_pred_ty, true>(L, R);
}
/// Matches a UMax with LHS and RHS in either order.
template <typename LHS, typename RHS>
-inline match_combine_or<MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty>,
- MaxMin_match<ICmpInst, RHS, LHS, umax_pred_ty>>
+inline MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty, true>
m_c_UMax(const LHS &L, const RHS &R) {
- return m_CombineOr(m_UMax(L, R), m_UMax(R, L));
+ return MaxMin_match<ICmpInst, LHS, RHS, umax_pred_ty, true>(L, R);
}
} // end namespace PatternMatch
diff --git a/include/llvm/IR/Statepoint.h b/include/llvm/IR/Statepoint.h
index 265e7eb348bf..630f30667272 100644
--- a/include/llvm/IR/Statepoint.h
+++ b/include/llvm/IR/Statepoint.h
@@ -62,7 +62,10 @@ bool isStatepoint(const Value *V);
bool isStatepoint(const Value &V);
bool isGCRelocate(ImmutableCallSite CS);
+bool isGCRelocate(const Value *V);
+
bool isGCResult(ImmutableCallSite CS);
+bool isGCResult(const Value *V);
/// Analogous to CallSiteBase, this provides most of the actual
/// functionality for Statepoint and ImmutableStatepoint. It is
diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h
index ccd40e576584..9e4914973edf 100644
--- a/include/llvm/IR/Value.h
+++ b/include/llvm/IR/Value.h
@@ -49,8 +49,9 @@ template<typename ValueTy> class StringMapEntry;
class StringRef;
class Twine;
class Type;
+class User;
-using ValueName = StringMapEntry<Value*>;
+using ValueName = StringMapEntry<Value *>;
//===----------------------------------------------------------------------===//
// Value Class
@@ -212,7 +213,7 @@ protected:
public:
Value(const Value &) = delete;
- void operator=(const Value &) = delete;
+ Value &operator=(const Value &) = delete;
/// Delete a pointer to a generic Value.
void deleteValue();
@@ -660,7 +661,7 @@ struct ValueDeleter { void operator()(Value *V) { V->deleteValue(); } };
/// Use this instead of std::unique_ptr<Value> or std::unique_ptr<Instruction>.
/// Those don't work because Value and Instruction's destructors are protected,
/// aren't virtual, and won't destroy the complete object.
-typedef std::unique_ptr<Value, ValueDeleter> unique_value;
+using unique_value = std::unique_ptr<Value, ValueDeleter>;
inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
V.print(OS);
diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h
index abb0aa3e3caf..a52fa3b542a5 100644
--- a/include/llvm/InitializePasses.h
+++ b/include/llvm/InitializePasses.h
@@ -192,7 +192,6 @@ void initializeLiveRangeShrinkPass(PassRegistry&);
void initializeLiveRegMatrixPass(PassRegistry&);
void initializeLiveStacksPass(PassRegistry&);
void initializeLiveVariablesPass(PassRegistry&);
-void initializeLoadCombinePass(PassRegistry&);
void initializeLoadStoreVectorizerPass(PassRegistry&);
void initializeLoaderPassPass(PassRegistry&);
void initializeLocalStackSlotPassPass(PassRegistry&);
diff --git a/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h b/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
index f9545333aabd..14f0c48266f0 100644
--- a/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
+++ b/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
@@ -177,7 +177,7 @@ public:
*/
void setMaxCacheSizeRelativeToAvailableSpace(unsigned Percentage) {
if (Percentage)
- CacheOptions.Policy.PercentageOfAvailableSpace = Percentage;
+ CacheOptions.Policy.MaxSizePercentageOfAvailableSpace = Percentage;
}
/**@}*/
diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h
index fb21e195b1df..a270973204f2 100644
--- a/include/llvm/MC/MCAsmBackend.h
+++ b/include/llvm/MC/MCAsmBackend.h
@@ -63,19 +63,16 @@ public:
/// Target hook to adjust the literal value of a fixup if necessary.
/// IsResolved signals whether the caller believes a relocation is needed; the
/// target can modify the value. The default does nothing.
- virtual void processFixupValue(const MCAssembler &Asm,
- const MCAsmLayout &Layout,
- const MCFixup &Fixup, const MCFragment *DF,
- const MCValue &Target, uint64_t &Value,
- bool &IsResolved) {}
+ virtual void processFixupValue(const MCAssembler &Asm, const MCFixup &Fixup,
+ const MCValue &Target, bool &IsResolved) {}
/// Apply the \p Value for given \p Fixup into the provided data fragment, at
/// the offset specified by the fixup and following the fixup kind as
/// appropriate. Errors (such as an out of range fixup value) should be
/// reported via \p Ctx.
- virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
- uint64_t Value, bool IsPCRel,
- MCContext &Ctx) const = 0;
+ virtual void applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
+ const MCValue &Target, MutableArrayRef<char> Data,
+ uint64_t Value, bool IsPCRel) const = 0;
/// @}
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index 63f7057a7076..4f1b5a8b3d72 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -195,8 +195,8 @@ private:
/// finishLayout - Finalize a layout, including fragment lowering.
void finishLayout(MCAsmLayout &Layout);
- std::pair<uint64_t, bool> handleFixup(const MCAsmLayout &Layout,
- MCFragment &F, const MCFixup &Fixup);
+ std::tuple<MCValue, uint64_t, bool>
+ handleFixup(const MCAsmLayout &Layout, MCFragment &F, const MCFixup &Fixup);
public:
/// Construct a new assembler instance.
@@ -413,7 +413,7 @@ public:
/// @}
- void dump();
+ void dump() const;
};
/// \brief Compute the amount of padding required before the fragment \p F to
diff --git a/include/llvm/MC/MCFragment.h b/include/llvm/MC/MCFragment.h
index 0aca922e3cf5..284ca50e19d5 100644
--- a/include/llvm/MC/MCFragment.h
+++ b/include/llvm/MC/MCFragment.h
@@ -130,7 +130,7 @@ public:
/// \brief Return true if given frgment has FT_Dummy type.
bool isDummy() const { return Kind == FT_Dummy; }
- void dump();
+ void dump() const;
};
class MCDummyFragment : public MCFragment {
diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h
index cc306d47250d..2771b1e67eab 100644
--- a/include/llvm/MC/MCSection.h
+++ b/include/llvm/MC/MCSection.h
@@ -167,7 +167,7 @@ public:
MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection);
- void dump();
+ void dump() const;
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
raw_ostream &OS,
diff --git a/include/llvm/MC/MCSymbolWasm.h b/include/llvm/MC/MCSymbolWasm.h
index 1b87095552d6..7ea89629efda 100644
--- a/include/llvm/MC/MCSymbolWasm.h
+++ b/include/llvm/MC/MCSymbolWasm.h
@@ -17,6 +17,7 @@ namespace llvm {
class MCSymbolWasm : public MCSymbol {
private:
bool IsFunction = false;
+ bool IsWeak = false;
std::string ModuleName;
SmallVector<wasm::ValType, 1> Returns;
SmallVector<wasm::ValType, 4> Params;
@@ -39,6 +40,9 @@ public:
bool isFunction() const { return IsFunction; }
void setIsFunction(bool isFunc) { IsFunction = isFunc; }
+ bool isWeak() const { return IsWeak; }
+ void setWeak(bool isWeak) { IsWeak = isWeak; }
+
const StringRef getModuleName() const { return ModuleName; }
const SmallVector<wasm::ValType, 1> &getReturns() const { return Returns; }
diff --git a/include/llvm/MC/MCValue.h b/include/llvm/MC/MCValue.h
index ead08fd90ca0..aa1eaf022c55 100644
--- a/include/llvm/MC/MCValue.h
+++ b/include/llvm/MC/MCValue.h
@@ -42,7 +42,7 @@ class MCValue {
int64_t Cst;
uint32_t RefKind;
public:
-
+ MCValue() : SymA(nullptr), SymB(nullptr), Cst(0), RefKind(0) {}
int64_t getConstant() const { return Cst; }
const MCSymbolRefExpr *getSymA() const { return SymA; }
const MCSymbolRefExpr *getSymB() const { return SymB; }
diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h
index 57bed213aad4..6e14cefaa0ab 100644
--- a/include/llvm/MC/MCWinCOFFObjectWriter.h
+++ b/include/llvm/MC/MCWinCOFFObjectWriter.h
@@ -30,8 +30,8 @@ class raw_pwrite_stream;
virtual ~MCWinCOFFObjectTargetWriter() = default;
unsigned getMachine() const { return Machine; }
- virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
- bool IsCrossSection,
+ virtual unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
+ const MCFixup &Fixup, bool IsCrossSection,
const MCAsmBackend &MAB) const = 0;
virtual bool recordRelocation(const MCFixup &) const { return true; }
};
diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h
index ae695a529597..bf0172822d3f 100644
--- a/include/llvm/Object/COFF.h
+++ b/include/llvm/Object/COFF.h
@@ -562,8 +562,26 @@ struct coff_tls_directory {
using coff_tls_directory32 = coff_tls_directory<support::little32_t>;
using coff_tls_directory64 = coff_tls_directory<support::little64_t>;
+/// Bits in control flow guard flags as we understand them.
+enum class coff_guard_flags : uint32_t {
+ CFInstrumented = 0x00000100,
+ HasFidTable = 0x00000400,
+ ProtectDelayLoadIAT = 0x00001000,
+ DelayLoadIATSection = 0x00002000, // Delay load in separate section
+ HasLongJmpTable = 0x00010000,
+ FidTableHasFlags = 0x10000000, // Indicates that fid tables are 5 bytes
+};
+
+struct coff_load_config_code_integrity {
+ support::ulittle16_t Flags;
+ support::ulittle16_t Catalog;
+ support::ulittle32_t CatalogOffset;
+ support::ulittle32_t Reserved;
+};
+
+/// 32-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY32)
struct coff_load_configuration32 {
- support::ulittle32_t Characteristics;
+ support::ulittle32_t Size;
support::ulittle32_t TimeDateStamp;
support::ulittle16_t MajorVersion;
support::ulittle16_t MinorVersion;
@@ -578,34 +596,81 @@ struct coff_load_configuration32 {
support::ulittle32_t ProcessAffinityMask;
support::ulittle32_t ProcessHeapFlags;
support::ulittle16_t CSDVersion;
- support::ulittle16_t Reserved;
+ support::ulittle16_t DependentLoadFlags;
support::ulittle32_t EditList;
support::ulittle32_t SecurityCookie;
support::ulittle32_t SEHandlerTable;
support::ulittle32_t SEHandlerCount;
+
+ // Added in MSVC 2015 for /guard:cf.
+ support::ulittle32_t GuardCFCheckFunction;
+ support::ulittle32_t GuardCFCheckDispatch;
+ support::ulittle32_t GuardCFFunctionTable;
+ support::ulittle32_t GuardCFFunctionCount;
+ support::ulittle32_t GuardFlags; // coff_guard_flags
+
+ // Added in MSVC 2017
+ coff_load_config_code_integrity CodeIntegrity;
+ support::ulittle32_t GuardAddressTakenIatEntryTable;
+ support::ulittle32_t GuardAddressTakenIatEntryCount;
+ support::ulittle32_t GuardLongJumpTargetTable;
+ support::ulittle32_t GuardLongJumpTargetCount;
+ support::ulittle32_t DynamicValueRelocTable;
+ support::ulittle32_t CHPEMetadataPointer;
+ support::ulittle32_t GuardRFFailureRoutine;
+ support::ulittle32_t GuardRFFailureRoutineFunctionPointer;
+ support::ulittle32_t DynamicValueRelocTableOffset;
+ support::ulittle16_t DynamicValueRelocTableSection;
+ support::ulittle16_t Reserved2;
+ support::ulittle32_t GuardRFVerifyStackPointerFunctionPointer;
+ support::ulittle32_t HotPatchTableOffset;
};
+/// 64-bit load config (IMAGE_LOAD_CONFIG_DIRECTORY64)
struct coff_load_configuration64 {
- support::ulittle32_t Characteristics;
+ support::ulittle32_t Size;
support::ulittle32_t TimeDateStamp;
support::ulittle16_t MajorVersion;
support::ulittle16_t MinorVersion;
support::ulittle32_t GlobalFlagsClear;
support::ulittle32_t GlobalFlagsSet;
support::ulittle32_t CriticalSectionDefaultTimeout;
- support::ulittle32_t DeCommitFreeBlockThreshold;
- support::ulittle32_t DeCommitTotalFreeThreshold;
- support::ulittle32_t LockPrefixTable;
- support::ulittle32_t MaximumAllocationSize;
- support::ulittle32_t VirtualMemoryThreshold;
- support::ulittle32_t ProcessAffinityMask;
+ support::ulittle64_t DeCommitFreeBlockThreshold;
+ support::ulittle64_t DeCommitTotalFreeThreshold;
+ support::ulittle64_t LockPrefixTable;
+ support::ulittle64_t MaximumAllocationSize;
+ support::ulittle64_t VirtualMemoryThreshold;
+ support::ulittle64_t ProcessAffinityMask;
support::ulittle32_t ProcessHeapFlags;
support::ulittle16_t CSDVersion;
- support::ulittle16_t Reserved;
- support::ulittle32_t EditList;
+ support::ulittle16_t DependentLoadFlags;
+ support::ulittle64_t EditList;
support::ulittle64_t SecurityCookie;
support::ulittle64_t SEHandlerTable;
support::ulittle64_t SEHandlerCount;
+
+ // Added in MSVC 2015 for /guard:cf.
+ support::ulittle64_t GuardCFCheckFunction;
+ support::ulittle64_t GuardCFCheckDispatch;
+ support::ulittle64_t GuardCFFunctionTable;
+ support::ulittle64_t GuardCFFunctionCount;
+ support::ulittle32_t GuardFlags;
+
+ // Added in MSVC 2017
+ coff_load_config_code_integrity CodeIntegrity;
+ support::ulittle64_t GuardAddressTakenIatEntryTable;
+ support::ulittle64_t GuardAddressTakenIatEntryCount;
+ support::ulittle64_t GuardLongJumpTargetTable;
+ support::ulittle64_t GuardLongJumpTargetCount;
+ support::ulittle64_t DynamicValueRelocTable;
+ support::ulittle64_t CHPEMetadataPointer;
+ support::ulittle64_t GuardRFFailureRoutine;
+ support::ulittle64_t GuardRFFailureRoutineFunctionPointer;
+ support::ulittle32_t DynamicValueRelocTableOffset;
+ support::ulittle16_t DynamicValueRelocTableSection;
+ support::ulittle16_t Reserved2;
+ support::ulittle64_t GuardRFVerifyStackPointerFunctionPointer;
+ support::ulittle32_t HotPatchTableOffset;
};
struct coff_runtime_function_x64 {
@@ -684,6 +749,8 @@ private:
const coff_base_reloc_block_header *BaseRelocEnd;
const debug_directory *DebugDirectoryBegin;
const debug_directory *DebugDirectoryEnd;
+ // Either coff_load_configuration32 or coff_load_configuration64.
+ const void *LoadConfig;
std::error_code getString(uint32_t offset, StringRef &Res) const;
@@ -698,6 +765,7 @@ private:
std::error_code initExportTablePtr();
std::error_code initBaseRelocPtr();
std::error_code initDebugDirectoryPtr();
+ std::error_code initLoadConfigPtr();
public:
uintptr_t getSymbolTable() const {
@@ -775,6 +843,16 @@ public:
return getRawNumberOfSymbols();
}
+ const coff_load_configuration32 *getLoadConfig32() const {
+ assert(!is64());
+ return reinterpret_cast<const coff_load_configuration32 *>(LoadConfig);
+ }
+
+ const coff_load_configuration64 *getLoadConfig64() const {
+ assert(is64());
+ return reinterpret_cast<const coff_load_configuration64 *>(LoadConfig);
+ }
+
protected:
void moveSymbolNext(DataRefImpl &Symb) const override;
Expected<StringRef> getSymbolName(DataRefImpl Symb) const override;
diff --git a/include/llvm/Object/IRSymtab.h b/include/llvm/Object/IRSymtab.h
index 5b832141a865..502f133d307d 100644
--- a/include/llvm/Object/IRSymtab.h
+++ b/include/llvm/Object/IRSymtab.h
@@ -38,6 +38,7 @@
namespace llvm {
struct BitcodeFileContents;
+class StringTableBuilder;
namespace irsymtab {
@@ -136,9 +137,10 @@ struct Header {
} // end namespace storage
-/// Fills in Symtab and Strtab with a valid symbol and string table for Mods.
+/// Fills in Symtab and StrtabBuilder with a valid symbol and string table for
+/// Mods.
Error build(ArrayRef<Module *> Mods, SmallVector<char, 0> &Symtab,
- SmallVector<char, 0> &Strtab);
+ StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc);
/// This represents a symbol that has been read from a storage::Symbol and
/// possibly a storage::Uncommon.
diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h
index 3fc726f4ccb8..2c3c89d10546 100644
--- a/include/llvm/Object/MachO.h
+++ b/include/llvm/Object/MachO.h
@@ -304,6 +304,12 @@ public:
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
relocation_iterator section_rel_end(DataRefImpl Sec) const override;
+ relocation_iterator extrel_begin() const;
+ relocation_iterator extrel_end() const;
+ iterator_range<relocation_iterator> external_relocations() const {
+ return make_range(extrel_begin(), extrel_end());
+ }
+
void moveRelocationNext(DataRefImpl &Rel) const override;
uint64_t getRelocationOffset(DataRefImpl Rel) const override;
symbol_iterator getRelocationSymbol(DataRefImpl Rel) const override;
diff --git a/include/llvm/Object/Wasm.h b/include/llvm/Object/Wasm.h
index 10edc461b9e9..9d53131234f4 100644
--- a/include/llvm/Object/Wasm.h
+++ b/include/llvm/Object/Wasm.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringMap.h"
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/ObjectFile.h"
@@ -48,7 +49,24 @@ public:
StringRef Name;
SymbolType Type;
uint32_t Section;
+ uint32_t Flags = 0;
+
+ // Index into the imports, exports or functions array of the object depending
+ // on the type
uint32_t ElementIndex;
+
+ bool isWeak() const {
+ return Flags & wasm::WASM_SYMBOL_FLAG_WEAK;
+ }
+
+ void print(raw_ostream &Out) const {
+ Out << "Name=" << Name << ", Type=" << static_cast<int>(Type)
+ << ", Flags=" << Flags;
+ }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ LLVM_DUMP_METHOD void dump() const { print(dbgs()); }
+#endif
};
class WasmSection {
@@ -63,6 +81,7 @@ public:
};
class WasmObjectFile : public ObjectFile {
+
public:
WasmObjectFile(MemoryBufferRef Object, Error &Err);
@@ -176,6 +195,7 @@ private:
// Custom section types
Error parseNameSection(const uint8_t *Ptr, const uint8_t *End);
+ Error parseLinkingSection(const uint8_t *Ptr, const uint8_t *End);
Error parseRelocSection(StringRef Name, const uint8_t *Ptr,
const uint8_t *End);
@@ -190,13 +210,22 @@ private:
std::vector<wasm::WasmExport> Exports;
std::vector<wasm::WasmElemSegment> ElemSegments;
std::vector<wasm::WasmDataSegment> DataSegments;
- std::vector<WasmSymbol> Symbols;
std::vector<wasm::WasmFunction> Functions;
+ std::vector<WasmSymbol> Symbols;
ArrayRef<uint8_t> CodeSection;
uint32_t StartFunction = -1;
+
+ StringMap<uint32_t> SymbolMap;
};
} // end namespace object
+
+inline raw_ostream &operator<<(raw_ostream &OS,
+ const object::WasmSymbol &Sym) {
+ Sym.print(OS);
+ return OS;
+}
+
} // end namespace llvm
#endif // LLVM_OBJECT_WASM_H
diff --git a/include/llvm/Object/WindowsResource.h b/include/llvm/Object/WindowsResource.h
index 4839013c8228..3d32409fd4ac 100644
--- a/include/llvm/Object/WindowsResource.h
+++ b/include/llvm/Object/WindowsResource.h
@@ -30,7 +30,6 @@
#define LLVM_INCLUDE_LLVM_OBJECT_RESFILE_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/Binary.h"
#include "llvm/Object/Error.h"
@@ -44,14 +43,47 @@
#include <map>
namespace llvm {
-
-class FileOutputBuffer;
-
namespace object {
class WindowsResource;
-enum class Machine { UNKNOWN, ARM, X64, X86 };
+const size_t WIN_RES_MAGIC_SIZE = 16;
+const size_t WIN_RES_NULL_ENTRY_SIZE = 16;
+const uint32_t WIN_RES_HEADER_ALIGNMENT = 4;
+const uint32_t WIN_RES_DATA_ALIGNMENT = 4;
+const uint16_t WIN_RES_PURE_MOVEABLE = 0x0030;
+
+struct WinResHeaderPrefix {
+ support::ulittle32_t DataSize;
+ support::ulittle32_t HeaderSize;
+};
+
+// Type and Name may each either be an integer ID or a string. This struct is
+// only used in the case where they are both IDs.
+struct WinResIDs {
+ uint16_t TypeFlag;
+ support::ulittle16_t TypeID;
+ uint16_t NameFlag;
+ support::ulittle16_t NameID;
+
+ void setType(uint16_t ID) {
+ TypeFlag = 0xffff;
+ TypeID = ID;
+ }
+
+ void setName(uint16_t ID) {
+ NameFlag = 0xffff;
+ NameID = ID;
+ }
+};
+
+struct WinResHeaderSuffix {
+ support::ulittle32_t DataVersion;
+ support::ulittle16_t MemoryFlags;
+ support::ulittle16_t Language;
+ support::ulittle32_t Version;
+ support::ulittle32_t Characteristics;
+};
class ResourceEntryRef {
public:
@@ -76,14 +108,6 @@ private:
Error loadNext();
- struct HeaderSuffix {
- support::ulittle32_t DataVersion;
- support::ulittle16_t MemoryFlags;
- support::ulittle16_t Language;
- support::ulittle32_t Version;
- support::ulittle32_t Characteristics;
- };
-
BinaryStreamReader Reader;
bool IsStringType;
ArrayRef<UTF16> Type;
@@ -91,7 +115,7 @@ private:
bool IsStringName;
ArrayRef<UTF16> Name;
uint16_t NameID;
- const HeaderSuffix *Suffix = nullptr;
+ const WinResHeaderSuffix *Suffix = nullptr;
ArrayRef<uint8_t> Data;
const WindowsResource *OwningRes = nullptr;
};
@@ -185,8 +209,9 @@ private:
std::vector<std::vector<UTF16>> StringTable;
};
-Error writeWindowsResourceCOFF(StringRef OutputFile, Machine MachineType,
- const WindowsResourceParser &Parser);
+Expected<std::unique_ptr<MemoryBuffer>>
+writeWindowsResourceCOFF(llvm::COFF::MachineTypes MachineType,
+ const WindowsResourceParser &Parser);
} // namespace object
} // namespace llvm
diff --git a/include/llvm/ObjectYAML/WasmYAML.h b/include/llvm/ObjectYAML/WasmYAML.h
index 447dbd7a603d..74f5664c43ac 100644
--- a/include/llvm/ObjectYAML/WasmYAML.h
+++ b/include/llvm/ObjectYAML/WasmYAML.h
@@ -112,8 +112,13 @@ struct Signature {
ValueType ReturnType;
};
+struct SymbolInfo {
+ StringRef Name;
+ uint32_t Flags;
+};
+
struct Section {
- Section(SectionType SecType) : Type(SecType) {}
+ explicit Section(SectionType SecType) : Type(SecType) {}
virtual ~Section();
SectionType Type;
@@ -121,20 +126,36 @@ struct Section {
};
struct CustomSection : Section {
- CustomSection() : Section(wasm::WASM_SEC_CUSTOM) {}
+ explicit CustomSection(StringRef Name)
+ : Section(wasm::WASM_SEC_CUSTOM), Name(Name) {}
static bool classof(const Section *S) {
return S->Type == wasm::WASM_SEC_CUSTOM;
}
StringRef Name;
yaml::BinaryRef Payload;
+};
+
+struct NameSection : CustomSection {
+ NameSection() : CustomSection("name") {}
+ static bool classof(const Section *S) {
+ auto C = dyn_cast<CustomSection>(S);
+ return C && C->Name == "name";
+ }
- // The follow is used by the "name" custom section.
- // TODO(sbc): Add support for more then just functions names. The wasm
- // name section can support multiple sub-sections.
std::vector<NameEntry> FunctionNames;
};
+struct LinkingSection : CustomSection {
+ LinkingSection() : CustomSection("linking") {}
+ static bool classof(const Section *S) {
+ auto C = dyn_cast<CustomSection>(S);
+ return C && C->Name == "linking";
+ }
+
+ std::vector<SymbolInfo> SymbolInfos;
+};
+
struct TypeSection : Section {
TypeSection() : Section(wasm::WASM_SEC_TYPE) {}
static bool classof(const Section *S) {
@@ -256,6 +277,7 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Function)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::LocalDecl)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::Relocation)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::NameEntry)
+LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::WasmYAML::SymbolInfo)
LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t)
namespace llvm {
@@ -329,6 +351,10 @@ template <> struct MappingTraits<WasmYAML::ElemSegment> {
static void mapping(IO &IO, WasmYAML::ElemSegment &Segment);
};
+template <> struct MappingTraits<WasmYAML::SymbolInfo> {
+ static void mapping(IO &IO, WasmYAML::SymbolInfo &Info);
+};
+
template <> struct ScalarEnumerationTraits<WasmYAML::ValueType> {
static void enumeration(IO &IO, WasmYAML::ValueType &Type);
};
diff --git a/include/llvm/Option/OptParser.td b/include/llvm/Option/OptParser.td
index 4da86f09750d..481223698719 100644
--- a/include/llvm/Option/OptParser.td
+++ b/include/llvm/Option/OptParser.td
@@ -92,6 +92,7 @@ class Option<list<string> prefixes, string name, OptionKind kind> {
int NumArgs = 0;
string HelpText = ?;
string MetaVarName = ?;
+ string Values = ?;
list<OptionFlag> Flags = [];
OptionGroup Group = ?;
Option Alias = ?;
@@ -126,6 +127,7 @@ class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
class Group<OptionGroup group> { OptionGroup Group = group; }
class HelpText<string text> { string HelpText = text; }
class MetaVarName<string name> { string MetaVarName = name; }
+class Values<string value> { string Values = value; }
// Predefined options.
diff --git a/include/llvm/Option/OptTable.h b/include/llvm/Option/OptTable.h
index e0169b927319..3e7b019a0d4e 100644
--- a/include/llvm/Option/OptTable.h
+++ b/include/llvm/Option/OptTable.h
@@ -53,6 +53,7 @@ public:
unsigned short GroupID;
unsigned short AliasID;
const char *AliasArgs;
+ const char *Values;
};
private:
@@ -120,6 +121,19 @@ public:
return getInfo(id).MetaVar;
}
+ /// Find possible value for given flags. This is used for shell
+ /// autocompletion.
+ ///
+ /// \param [in] Option - Key flag like "-stdlib=" when "-stdlib=l"
+ /// was passed to clang.
+ ///
+ /// \param [in] Arg - Value which we want to autocomplete like "l"
+ /// when "-stdlib=l" was passed to clang.
+ ///
+ /// \return The vector of possible values.
+ std::vector<std::string> suggestValueCompletions(StringRef Option,
+ StringRef Arg) const;
+
/// Find flags from OptTable which starts with Cur.
///
/// \param [in] Cur - String prefix that all returned flags need
diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h
index c08834f90598..d9aebd5b0757 100644
--- a/include/llvm/Option/Option.h
+++ b/include/llvm/Option/Option.h
@@ -57,6 +57,7 @@ public:
UnknownClass,
FlagClass,
JoinedClass,
+ ValuesClass,
SeparateClass,
RemainingArgsClass,
RemainingArgsJoinedClass,
@@ -155,6 +156,7 @@ public:
case CommaJoinedClass:
return RenderCommaJoinedStyle;
case FlagClass:
+ case ValuesClass:
case SeparateClass:
case MultiArgClass:
case JoinedOrSeparateClass:
diff --git a/include/llvm/ProfileData/Coverage/CoverageMapping.h b/include/llvm/ProfileData/Coverage/CoverageMapping.h
index b2f73fda2bae..0ba792e8dc43 100644
--- a/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -411,9 +411,11 @@ public:
std::vector<CoverageSegment>::const_iterator begin() const {
return Segments.begin();
}
+
std::vector<CoverageSegment>::const_iterator end() const {
return Segments.end();
}
+
bool empty() const { return Segments.empty(); }
/// \brief Expansions that can be further processed.
@@ -430,6 +432,7 @@ class CoverageMapping {
unsigned MismatchedFunctionCount = 0;
CoverageMapping() = default;
+
/// \brief Add a function record corresponding to \p Record.
Error loadFunctionRecord(const CoverageMappingRecord &Record,
IndexedInstrProfReader &ProfileReader);
@@ -607,13 +610,13 @@ enum CovMapVersion {
};
template <int CovMapVersion, class IntPtrT> struct CovMapTraits {
- typedef CovMapFunctionRecord CovMapFuncRecordType;
- typedef uint64_t NameRefType;
+ using CovMapFuncRecordType = CovMapFunctionRecord;
+ using NameRefType = uint64_t;
};
template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
- typedef CovMapFunctionRecordV1<IntPtrT> CovMapFuncRecordType;
- typedef IntPtrT NameRefType;
+ using CovMapFuncRecordType = CovMapFunctionRecordV1<IntPtrT>;
+ using NameRefType = IntPtrT;
};
} // end namespace coverage
@@ -622,6 +625,7 @@ template <class IntPtrT> struct CovMapTraits<CovMapVersion::Version1, IntPtrT> {
template<> struct DenseMapInfo<coverage::CounterExpression> {
static inline coverage::CounterExpression getEmptyKey() {
using namespace coverage;
+
return CounterExpression(CounterExpression::ExprKind::Subtract,
Counter::getCounter(~0U),
Counter::getCounter(~0U));
@@ -629,6 +633,7 @@ template<> struct DenseMapInfo<coverage::CounterExpression> {
static inline coverage::CounterExpression getTombstoneKey() {
using namespace coverage;
+
return CounterExpression(CounterExpression::ExprKind::Add,
Counter::getCounter(~0U),
Counter::getCounter(~0U));
diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h
index 0dbb2cf9f269..573ea90cfd00 100644
--- a/include/llvm/ProfileData/InstrProf.h
+++ b/include/llvm/ProfileData/InstrProf.h
@@ -410,7 +410,7 @@ uint64_t ComputeHash(StringRef K);
/// on how PGO name is formed.
class InstrProfSymtab {
public:
- typedef std::vector<std::pair<uint64_t, uint64_t>> AddrHashMap;
+ using AddrHashMap = std::vector<std::pair<uint64_t, uint64_t>>;
private:
StringRef Data;
@@ -450,11 +450,11 @@ public:
/// decls from module \c M. This interface is used by transformation
/// passes such as indirect function call promotion. Variable \c InLTO
/// indicates if this is called from LTO optimization passes.
- void create(Module &M, bool InLTO = false);
+ Error create(Module &M, bool InLTO = false);
/// Create InstrProfSymtab from a set of names iteratable from
/// \p IterRange. This interface is used by IndexedProfReader.
- template <typename NameIterRange> void create(const NameIterRange &IterRange);
+ template <typename NameIterRange> Error create(const NameIterRange &IterRange);
// If the symtab is created by a series of calls to \c addFuncName, \c
// finalizeSymtab needs to be called before looking up function names.
@@ -464,11 +464,14 @@ public:
/// Update the symtab by adding \p FuncName to the table. This interface
/// is used by the raw and text profile readers.
- void addFuncName(StringRef FuncName) {
+ Error addFuncName(StringRef FuncName) {
+ if (FuncName.empty())
+ return make_error<InstrProfError>(instrprof_error::malformed);
auto Ins = NameTab.insert(FuncName);
if (Ins.second)
MD5NameMap.push_back(std::make_pair(
IndexedInstrProf::ComputeHash(FuncName), Ins.first->getKey()));
+ return Error::success();
}
/// Map a function address to its name's MD5 hash. This interface
@@ -511,11 +514,13 @@ Error InstrProfSymtab::create(StringRef NameStrings) {
}
template <typename NameIterRange>
-void InstrProfSymtab::create(const NameIterRange &IterRange) {
+Error InstrProfSymtab::create(const NameIterRange &IterRange) {
for (auto Name : IterRange)
- addFuncName(Name);
+ if (Error E = addFuncName(Name))
+ return E;
finalizeSymtab();
+ return Error::success();
}
void InstrProfSymtab::finalizeSymtab() {
@@ -594,7 +599,7 @@ struct InstrProfRecord {
InstrProfRecord(StringRef Name, uint64_t Hash, std::vector<uint64_t> Counts)
: Name(Name), Hash(Hash), Counts(std::move(Counts)) {}
- typedef std::vector<std::pair<uint64_t, uint64_t>> ValueMapType;
+ using ValueMapType = std::vector<std::pair<uint64_t, uint64_t>>;
/// Return the number of value profile kinds with non-zero number
/// of profile sites.
@@ -668,8 +673,8 @@ struct InstrProfRecord {
private:
std::vector<InstrProfValueSiteRecord> IndirectCallSites;
std::vector<InstrProfValueSiteRecord> MemOPSizes;
- const std::vector<InstrProfValueSiteRecord> &
+ const std::vector<InstrProfValueSiteRecord> &
getValueSitesForKind(uint32_t ValueKind) const {
switch (ValueKind) {
case IPVK_IndirectCallTarget:
@@ -873,6 +878,11 @@ struct Summary {
// The number of Cutoff Entries (Summary::Entry) following summary fields.
uint64_t NumCutoffEntries;
+ Summary() = delete;
+ Summary(uint32_t Size) { memset(this, 0, Size); }
+
+ void operator delete(void *ptr) { ::operator delete(ptr); }
+
static uint32_t getSize(uint32_t NumSumFields, uint32_t NumCutoffEntries) {
return sizeof(Summary) + NumCutoffEntries * sizeof(Entry) +
NumSumFields * sizeof(uint64_t);
@@ -911,11 +921,6 @@ struct Summary {
ER.MinBlockCount = E.MinCount;
ER.NumBlocks = E.NumCounts;
}
-
- Summary(uint32_t Size) { memset(this, 0, Size); }
- void operator delete(void *ptr) { ::operator delete(ptr); }
-
- Summary() = delete;
};
inline std::unique_ptr<Summary> allocSummary(uint32_t TotalSize) {
diff --git a/include/llvm/ProfileData/InstrProfReader.h b/include/llvm/ProfileData/InstrProfReader.h
index 1d85a7149afc..8163ca159209 100644
--- a/include/llvm/ProfileData/InstrProfReader.h
+++ b/include/llvm/ProfileData/InstrProfReader.h
@@ -92,6 +92,7 @@ public:
protected:
std::unique_ptr<InstrProfSymtab> Symtab;
+
/// Set the current error and return same.
Error error(instrprof_error Err) {
LastError = Err;
@@ -202,7 +203,7 @@ private:
public:
RawInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
- : DataBuffer(std::move(DataBuffer)) { }
+ : DataBuffer(std::move(DataBuffer)) {}
RawInstrProfReader(const RawInstrProfReader &) = delete;
RawInstrProfReader &operator=(const RawInstrProfReader &) = delete;
@@ -268,8 +269,8 @@ private:
}
};
-typedef RawInstrProfReader<uint32_t> RawInstrProfReader32;
-typedef RawInstrProfReader<uint64_t> RawInstrProfReader64;
+using RawInstrProfReader32 = RawInstrProfReader<uint32_t>;
+using RawInstrProfReader64 = RawInstrProfReader<uint64_t>;
namespace IndexedInstrProf {
@@ -292,12 +293,12 @@ public:
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
: HashType(HashType), FormatVersion(FormatVersion) {}
- typedef ArrayRef<InstrProfRecord> data_type;
+ using data_type = ArrayRef<InstrProfRecord>;
- typedef StringRef internal_key_type;
- typedef StringRef external_key_type;
- typedef uint64_t hash_value_type;
- typedef uint64_t offset_type;
+ using internal_key_type = StringRef;
+ using external_key_type = StringRef;
+ using hash_value_type = uint64_t;
+ using offset_type = uint64_t;
static bool EqualKey(StringRef A, StringRef B) { return A == B; }
static StringRef GetInternalKey(StringRef K) { return K; }
@@ -343,15 +344,14 @@ struct InstrProfReaderIndexBase {
virtual void setValueProfDataEndianness(support::endianness Endianness) = 0;
virtual uint64_t getVersion() const = 0;
virtual bool isIRLevelProfile() const = 0;
- virtual void populateSymtab(InstrProfSymtab &) = 0;
+ virtual Error populateSymtab(InstrProfSymtab &) = 0;
};
-typedef OnDiskIterableChainedHashTable<InstrProfLookupTrait>
- OnDiskHashTableImplV3;
+using OnDiskHashTableImplV3 =
+ OnDiskIterableChainedHashTable<InstrProfLookupTrait>;
template <typename HashTableImpl>
class InstrProfReaderIndex : public InstrProfReaderIndexBase {
-
private:
std::unique_ptr<HashTableImpl> HashTable;
typename HashTableImpl::data_iterator RecordIterator;
@@ -383,8 +383,8 @@ public:
return (FormatVersion & VARIANT_MASK_IR_PROF) != 0;
}
- void populateSymtab(InstrProfSymtab &Symtab) override {
- Symtab.create(HashTable->keys());
+ Error populateSymtab(InstrProfSymtab &Symtab) override {
+ return Symtab.create(HashTable->keys());
}
};
diff --git a/include/llvm/ProfileData/InstrProfWriter.h b/include/llvm/ProfileData/InstrProfWriter.h
index 10742c0228eb..fff10af30295 100644
--- a/include/llvm/ProfileData/InstrProfWriter.h
+++ b/include/llvm/ProfileData/InstrProfWriter.h
@@ -29,10 +29,11 @@ namespace llvm {
/// Writer for instrumentation based profile data.
class InstrProfRecordWriterTrait;
class ProfOStream;
+class raw_fd_ostream;
class InstrProfWriter {
public:
- typedef SmallDenseMap<uint64_t, InstrProfRecord, 1> ProfilingData;
+ using ProfilingData = SmallDenseMap<uint64_t, InstrProfRecord, 1>;
enum ProfKind { PF_Unknown = 0, PF_FE, PF_IRLevel };
private:
@@ -58,7 +59,7 @@ public:
void write(raw_fd_ostream &OS);
/// Write the profile in text format to \c OS
- void writeText(raw_fd_ostream &OS);
+ Error writeText(raw_fd_ostream &OS);
/// Write \c Record in text format to \c OS
static void writeRecordInText(const InstrProfRecord &Record,
diff --git a/include/llvm/ProfileData/SampleProf.h b/include/llvm/ProfileData/SampleProf.h
index 7a705ca5416d..7fc258831be8 100644
--- a/include/llvm/ProfileData/SampleProf.h
+++ b/include/llvm/ProfileData/SampleProf.h
@@ -125,7 +125,7 @@ raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc);
/// will be a list of one or more functions.
class SampleRecord {
public:
- typedef StringMap<uint64_t> CallTargetMap;
+ using CallTargetMap = StringMap<uint64_t>;
SampleRecord() = default;
@@ -182,10 +182,11 @@ private:
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
-typedef std::map<LineLocation, SampleRecord> BodySampleMap;
class FunctionSamples;
-typedef StringMap<FunctionSamples> FunctionSamplesMap;
-typedef std::map<LineLocation, FunctionSamplesMap> CallsiteSampleMap;
+
+using BodySampleMap = std::map<LineLocation, SampleRecord>;
+using FunctionSamplesMap = StringMap<FunctionSamples>;
+using CallsiteSampleMap = std::map<LineLocation, FunctionSamplesMap>;
/// Representation of the samples collected for a function.
///
@@ -398,8 +399,8 @@ raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
/// order of LocationT.
template <class LocationT, class SampleT> class SampleSorter {
public:
- typedef std::pair<const LocationT, SampleT> SamplesWithLoc;
- typedef SmallVector<const SamplesWithLoc *, 20> SamplesWithLocList;
+ using SamplesWithLoc = std::pair<const LocationT, SampleT>;
+ using SamplesWithLocList = SmallVector<const SamplesWithLoc *, 20>;
SampleSorter(const std::map<LocationT, SampleT> &Samples) {
for (const auto &I : Samples)
diff --git a/include/llvm/ProfileData/SampleProfReader.h b/include/llvm/ProfileData/SampleProfReader.h
index 29e3aba3e0e7..9c1f357cbbd1 100644
--- a/include/llvm/ProfileData/SampleProfReader.h
+++ b/include/llvm/ProfileData/SampleProfReader.h
@@ -350,7 +350,7 @@ public:
class SampleProfileReaderBinary : public SampleProfileReader {
public:
SampleProfileReaderBinary(std::unique_ptr<MemoryBuffer> B, LLVMContext &C)
- : SampleProfileReader(std::move(B), C), Data(nullptr), End(nullptr) {}
+ : SampleProfileReader(std::move(B), C) {}
/// \brief Read and validate the file header.
std::error_code readHeader() override;
@@ -388,10 +388,10 @@ protected:
std::error_code readProfile(FunctionSamples &FProfile);
/// \brief Points to the current location in the buffer.
- const uint8_t *Data;
+ const uint8_t *Data = nullptr;
/// \brief Points to the end of the buffer.
- const uint8_t *End;
+ const uint8_t *End = nullptr;
/// Function name table.
std::vector<StringRef> NameTable;
@@ -403,7 +403,7 @@ private:
std::error_code readSummary();
};
-typedef SmallVector<FunctionSamples *, 10> InlineCallStack;
+using InlineCallStack = SmallVector<FunctionSamples *, 10>;
// Supported histogram types in GCC. Currently, we only need support for
// call target histograms.
diff --git a/include/llvm/Support/BinaryStreamReader.h b/include/llvm/Support/BinaryStreamReader.h
index 738c042add3e..ae5ebb2c3628 100644
--- a/include/llvm/Support/BinaryStreamReader.h
+++ b/include/llvm/Support/BinaryStreamReader.h
@@ -137,6 +137,15 @@ public:
/// returns an appropriate error code.
Error readStreamRef(BinaryStreamRef &Ref, uint32_t Length);
+ /// Read \p Length bytes from the underlying stream into \p Stream. This is
+ /// equivalent to calling getUnderlyingStream().slice(Offset, Length).
+ /// Updates the stream's offset to point after the newly read object. Never
+ /// causes a copy.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readSubstream(BinarySubstreamRef &Stream, uint32_t Size);
+
/// Get a pointer to an object of type T from the underlying stream, as if by
/// memcpy, and store the result into \p Dest. It is up to the caller to
/// ensure that objects of type T can be safely treated in this manner.
diff --git a/include/llvm/Support/BinaryStreamRef.h b/include/llvm/Support/BinaryStreamRef.h
index e3bd4bf0860e..6d5135cb258d 100644
--- a/include/llvm/Support/BinaryStreamRef.h
+++ b/include/llvm/Support/BinaryStreamRef.h
@@ -166,6 +166,28 @@ public:
ArrayRef<uint8_t> &Buffer) const;
};
+struct BinarySubstreamRef {
+ uint32_t Offset; // Offset in the parent stream
+ BinaryStreamRef StreamData; // Stream Data
+
+ BinarySubstreamRef slice(uint32_t Off, uint32_t Size) const {
+ BinaryStreamRef SubSub = StreamData.slice(Off, Size);
+ return {Off + Offset, SubSub};
+ }
+ BinarySubstreamRef drop_front(uint32_t N) const {
+ return slice(N, size() - N);
+ }
+ BinarySubstreamRef keep_front(uint32_t N) const { return slice(0, N); }
+
+ std::pair<BinarySubstreamRef, BinarySubstreamRef>
+ split(uint32_t Offset) const {
+ return std::make_pair(keep_front(Offset), drop_front(Offset));
+ }
+
+ uint32_t size() const { return StreamData.getLength(); }
+ bool empty() const { return size() == 0; }
+};
+
class WritableBinaryStreamRef
: public BinaryStreamRefBase<WritableBinaryStreamRef,
WritableBinaryStream> {
diff --git a/include/llvm/Support/CachePruning.h b/include/llvm/Support/CachePruning.h
index e826938878e5..46e34358573b 100644
--- a/include/llvm/Support/CachePruning.h
+++ b/include/llvm/Support/CachePruning.h
@@ -39,8 +39,13 @@ struct CachePruningPolicy {
/// available space on the the disk. Set to 100 to indicate no limit, 50 to
/// indicate that the cache size will not be left over half the available disk
/// space. A value over 100 will be reduced to 100. A value of 0 disables the
- /// size-based pruning.
- unsigned PercentageOfAvailableSpace = 75;
+ /// percentage size-based pruning.
+ unsigned MaxSizePercentageOfAvailableSpace = 75;
+
+ /// The maximum size for the cache directory in bytes. A value over the amount
+ /// of available space on the disk will be reduced to the amount of available
+ /// space. A value of 0 disables the absolute size-based pruning.
+ uint64_t MaxSizeBytes = 0;
};
/// Parse the given string as a cache pruning policy. Defaults are taken from a
diff --git a/include/llvm/Support/DataExtractor.h b/include/llvm/Support/DataExtractor.h
index 380b628fd95f..31447882a919 100644
--- a/include/llvm/Support/DataExtractor.h
+++ b/include/llvm/Support/DataExtractor.h
@@ -14,6 +14,30 @@
#include "llvm/Support/DataTypes.h"
namespace llvm {
+
+/// An auxiliary type to facilitate extraction of 3-byte entities.
+struct Uint24 {
+ uint8_t Bytes[3];
+ Uint24(uint8_t U) {
+ Bytes[0] = Bytes[1] = Bytes[2] = U;
+ }
+ Uint24(uint8_t U0, uint8_t U1, uint8_t U2) {
+ Bytes[0] = U0; Bytes[1] = U1; Bytes[2] = U2;
+ }
+ uint32_t getAsUint32(bool IsLittleEndian) const {
+ int LoIx = IsLittleEndian ? 0 : 2;
+ return Bytes[LoIx] + (Bytes[1] << 8) + (Bytes[2-LoIx] << 16);
+ }
+};
+
+using uint24_t = Uint24;
+static_assert(sizeof(uint24_t) == 3, "sizeof(uint24_t) != 3");
+
+/// Needed by swapByteOrder().
+inline uint24_t getSwappedBytes(uint24_t C) {
+ return uint24_t(C.Bytes[2], C.Bytes[1], C.Bytes[0]);
+}
+
class DataExtractor {
StringRef Data;
uint8_t IsLittleEndian;
@@ -236,6 +260,23 @@ public:
/// NULL otherise.
uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const;
+ /// Extract a 24-bit unsigned value from \a *offset_ptr and return it
+ /// in a uint32_t.
+ ///
+ /// Extract 3 bytes from the binary data at the offset pointed to by
+ /// \a offset_ptr, construct a uint32_t from them and update the offset
+ /// on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the 3 bytes if the value is extracted correctly. If the offset
+ /// is out of bounds or there are not enough bytes to extract this value,
+ /// the offset will be left unmodified.
+ ///
+ /// @return
+ /// The extracted 24-bit value represented in a uint32_t.
+ uint32_t getU24(uint32_t *offset_ptr) const;
+
/// Extract a uint32_t value from \a *offset_ptr.
///
/// Extract a single uint32_t from the binary data at the offset
diff --git a/include/llvm/Support/Errno.h b/include/llvm/Support/Errno.h
index 8e145c7b0b51..4ce65e7dc83c 100644
--- a/include/llvm/Support/Errno.h
+++ b/include/llvm/Support/Errno.h
@@ -14,6 +14,7 @@
#ifndef LLVM_SUPPORT_ERRNO_H
#define LLVM_SUPPORT_ERRNO_H
+#include <cerrno>
#include <string>
namespace llvm {
diff --git a/include/llvm/Support/Error.h b/include/llvm/Support/Error.h
index 1e27e0b821f0..9a7fa0ae6356 100644
--- a/include/llvm/Support/Error.h
+++ b/include/llvm/Support/Error.h
@@ -1076,6 +1076,27 @@ T cantFail(Expected<T> ValOrErr) {
llvm_unreachable("Failure value returned from cantFail wrapped call");
}
+/// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and
+/// returns the contained reference.
+///
+/// This function can be used to wrap calls to fallible functions ONLY when it
+/// is known that the Error will always be a success value. E.g.
+///
+/// @code{.cpp}
+/// // foo only attempts the fallible operation if DoFallibleOperation is
+/// // true. If DoFallibleOperation is false then foo always returns a Bar&.
+/// Expected<Bar&> foo(bool DoFallibleOperation);
+///
+/// Bar &X = cantFail(foo(false));
+/// @endcode
+template <typename T>
+T& cantFail(Expected<T&> ValOrErr) {
+ if (ValOrErr)
+ return *ValOrErr;
+ else
+ llvm_unreachable("Failure value returned from cantFail wrapped call");
+}
+
} // end namespace llvm
#endif // LLVM_SUPPORT_ERROR_H
diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h
index 268c53c50252..02016e7dbd62 100644
--- a/include/llvm/Support/GCOV.h
+++ b/include/llvm/Support/GCOV.h
@@ -271,8 +271,8 @@ struct GCOVEdge {
/// GCOVFunction - Collects function information.
class GCOVFunction {
public:
- typedef pointee_iterator<SmallVectorImpl<
- std::unique_ptr<GCOVBlock>>::const_iterator> BlockIterator;
+ using BlockIterator = pointee_iterator<SmallVectorImpl<
+ std::unique_ptr<GCOVBlock>>::const_iterator>;
GCOVFunction(GCOVFile &P) : Parent(P) {}
@@ -321,7 +321,7 @@ class GCOVBlock {
};
public:
- typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator;
+ using EdgeIterator = SmallVectorImpl<GCOVEdge *>::const_iterator;
GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
~GCOVBlock();
@@ -381,10 +381,10 @@ class FileInfo {
// Therefore this typedef allows LineData.Functions to store multiple
// functions
// per instance. This is rare, however, so optimize for the common case.
- typedef SmallVector<const GCOVFunction *, 1> FunctionVector;
- typedef DenseMap<uint32_t, FunctionVector> FunctionLines;
- typedef SmallVector<const GCOVBlock *, 4> BlockVector;
- typedef DenseMap<uint32_t, BlockVector> BlockLines;
+ using FunctionVector = SmallVector<const GCOVFunction *, 1>;
+ using FunctionLines = DenseMap<uint32_t, FunctionVector>;
+ using BlockVector = SmallVector<const GCOVBlock *, 4>;
+ using BlockLines = DenseMap<uint32_t, BlockVector>;
struct LineData {
LineData() = default;
@@ -448,8 +448,8 @@ private:
uint32_t RunCount = 0;
uint32_t ProgramCount = 0;
- typedef SmallVector<std::pair<std::string, GCOVCoverage>, 4> FileCoverageList;
- typedef MapVector<const GCOVFunction *, GCOVCoverage> FuncCoverageMap;
+ using FileCoverageList = SmallVector<std::pair<std::string, GCOVCoverage>, 4>;
+ using FuncCoverageMap = MapVector<const GCOVFunction *, GCOVCoverage>;
FileCoverageList FileCoverages;
FuncCoverageMap FuncCoverages;
diff --git a/include/llvm/Support/GenericDomTree.h b/include/llvm/Support/GenericDomTree.h
index 80a2dfcbad88..601633d41cff 100644
--- a/include/llvm/Support/GenericDomTree.h
+++ b/include/llvm/Support/GenericDomTree.h
@@ -69,14 +69,13 @@ protected:
: Roots(), IsPostDominators(isPostDom) {}
DominatorBase(DominatorBase &&Arg)
- : Roots(std::move(Arg.Roots)),
- IsPostDominators(std::move(Arg.IsPostDominators)) {
+ : Roots(std::move(Arg.Roots)), IsPostDominators(Arg.IsPostDominators) {
Arg.Roots.clear();
}
DominatorBase &operator=(DominatorBase &&RHS) {
Roots = std::move(RHS.Roots);
- IsPostDominators = std::move(RHS.IsPostDominators);
+ IsPostDominators = RHS.IsPostDominators;
RHS.Roots.clear();
return *this;
}
@@ -99,18 +98,17 @@ template <class NodeT> class DomTreeNodeBase {
template <class N> friend class DominatorTreeBase;
NodeT *TheBB;
- DomTreeNodeBase<NodeT> *IDom;
- std::vector<DomTreeNodeBase<NodeT> *> Children;
- mutable int DFSNumIn = -1;
- mutable int DFSNumOut = -1;
+ DomTreeNodeBase *IDom;
+ std::vector<DomTreeNodeBase *> Children;
+ mutable unsigned DFSNumIn = ~0;
+ mutable unsigned DFSNumOut = ~0;
-public:
- DomTreeNodeBase(NodeT *BB, DomTreeNodeBase<NodeT> *iDom)
- : TheBB(BB), IDom(iDom) {}
+ public:
+ DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom) : TheBB(BB), IDom(iDom) {}
- typedef typename std::vector<DomTreeNodeBase<NodeT> *>::iterator iterator;
- typedef typename std::vector<DomTreeNodeBase<NodeT> *>::const_iterator
- const_iterator;
+ using iterator = typename std::vector<DomTreeNodeBase *>::iterator;
+ using const_iterator =
+ typename std::vector<DomTreeNodeBase *>::const_iterator;
iterator begin() { return Children.begin(); }
iterator end() { return Children.end(); }
@@ -118,14 +116,12 @@ public:
const_iterator end() const { return Children.end(); }
NodeT *getBlock() const { return TheBB; }
- DomTreeNodeBase<NodeT> *getIDom() const { return IDom; }
+ DomTreeNodeBase *getIDom() const { return IDom; }
- const std::vector<DomTreeNodeBase<NodeT> *> &getChildren() const {
- return Children;
- }
+ const std::vector<DomTreeNodeBase *> &getChildren() const { return Children; }
- std::unique_ptr<DomTreeNodeBase<NodeT>>
- addChild(std::unique_ptr<DomTreeNodeBase<NodeT>> C) {
+ std::unique_ptr<DomTreeNodeBase> addChild(
+ std::unique_ptr<DomTreeNodeBase> C) {
Children.push_back(C.get());
return C;
}
@@ -134,7 +130,7 @@ public:
void clearAllChildren() { Children.clear(); }
- bool compare(const DomTreeNodeBase<NodeT> *Other) const {
+ bool compare(const DomTreeNodeBase *Other) const {
if (getNumChildren() != Other->getNumChildren())
return true;
@@ -152,10 +148,10 @@ public:
return false;
}
- void setIDom(DomTreeNodeBase<NodeT> *NewIDom) {
+ void setIDom(DomTreeNodeBase *NewIDom) {
assert(IDom && "No immediate dominator?");
if (IDom != NewIDom) {
- typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I =
+ typename std::vector<DomTreeNodeBase *>::iterator I =
find(IDom->Children, this);
assert(I != IDom->Children.end() &&
"Not in immediate dominator children set!");
@@ -177,32 +173,32 @@ public:
private:
// Return true if this node is dominated by other. Use this only if DFS info
// is valid.
- bool DominatedBy(const DomTreeNodeBase<NodeT> *other) const {
+ bool DominatedBy(const DomTreeNodeBase *other) const {
return this->DFSNumIn >= other->DFSNumIn &&
this->DFSNumOut <= other->DFSNumOut;
}
};
template <class NodeT>
-raw_ostream &operator<<(raw_ostream &o, const DomTreeNodeBase<NodeT> *Node) {
+raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeBase<NodeT> *Node) {
if (Node->getBlock())
- Node->getBlock()->printAsOperand(o, false);
+ Node->getBlock()->printAsOperand(O, false);
else
- o << " <<exit node>>";
+ O << " <<exit node>>";
- o << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "}";
+ O << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "}";
- return o << "\n";
+ return O << "\n";
}
template <class NodeT>
-void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &o,
+void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &O,
unsigned Lev) {
- o.indent(2 * Lev) << "[" << Lev << "] " << N;
+ O.indent(2 * Lev) << "[" << Lev << "] " << N;
for (typename DomTreeNodeBase<NodeT>::const_iterator I = N->begin(),
E = N->end();
I != E; ++I)
- PrintDomTree<NodeT>(*I, o, Lev + 1);
+ PrintDomTree<NodeT>(*I, O, Lev + 1);
}
// The calculate routine is provided in a separate header but referenced here.
@@ -239,8 +235,8 @@ template <class NodeT> class DominatorTreeBase : public DominatorBase<NodeT> {
}
protected:
- typedef DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>
- DomTreeNodeMapType;
+ using DomTreeNodeMapType =
+ DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>;
DomTreeNodeMapType DomTreeNodes;
DomTreeNodeBase<NodeT> *RootNode;
@@ -663,19 +659,18 @@ public:
/// print - Convert to human readable form
///
- void print(raw_ostream &o) const {
- o << "=============================--------------------------------\n";
+ void print(raw_ostream &O) const {
+ O << "=============================--------------------------------\n";
if (this->isPostDominator())
- o << "Inorder PostDominator Tree: ";
+ O << "Inorder PostDominator Tree: ";
else
- o << "Inorder Dominator Tree: ";
+ O << "Inorder Dominator Tree: ";
if (!DFSInfoValid)
- o << "DFSNumbers invalid: " << SlowQueries << " slow queries.";
- o << "\n";
+ O << "DFSNumbers invalid: " << SlowQueries << " slow queries.";
+ O << "\n";
// The postdom tree can have a null root if there are no returns.
- if (getRootNode())
- PrintDomTree<NodeT>(getRootNode(), o, 1);
+ if (getRootNode()) PrintDomTree<NodeT>(getRootNode(), O, 1);
}
protected:
@@ -770,7 +765,7 @@ public:
/// recalculate - compute a dominator tree for the given function
template <class FT> void recalculate(FT &F) {
- typedef GraphTraits<FT *> TraitsTy;
+ using TraitsTy = GraphTraits<FT *>;
reset();
Vertex.push_back(nullptr);
diff --git a/include/llvm/Support/GenericDomTreeConstruction.h b/include/llvm/Support/GenericDomTreeConstruction.h
index c1d757f3ab6a..449c385bc86a 100644
--- a/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/include/llvm/Support/GenericDomTreeConstruction.h
@@ -35,10 +35,10 @@ namespace llvm {
// converting the one argument insert calls.
template <class NodeRef, class InfoType> struct df_iterator_dom_storage {
public:
- typedef DenseMap<NodeRef, InfoType> BaseSet;
+ using BaseSet = DenseMap<NodeRef, InfoType>;
df_iterator_dom_storage(BaseSet &Storage) : Storage(Storage) {}
- typedef typename BaseSet::iterator iterator;
+ using iterator = typename BaseSet::iterator;
std::pair<iterator, bool> insert(NodeRef N) {
return Storage.insert({N, InfoType()});
}
@@ -101,20 +101,22 @@ template <class GraphT>
typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT,
typename GraphT::NodeRef VIn,
unsigned LastLinked) {
+ using NodePtr = typename GraphT::NodeRef;
+
auto &VInInfo = DT.Info[VIn];
if (VInInfo.DFSNum < LastLinked)
return VIn;
- SmallVector<typename GraphT::NodeRef, 32> Work;
- SmallPtrSet<typename GraphT::NodeRef, 32> Visited;
+ SmallVector<NodePtr, 32> Work;
+ SmallPtrSet<NodePtr, 32> Visited;
if (VInInfo.Parent >= LastLinked)
Work.push_back(VIn);
while (!Work.empty()) {
- typename GraphT::NodeRef V = Work.back();
+ NodePtr V = Work.back();
auto &VInfo = DT.Info[V];
- typename GraphT::NodeRef VAncestor = DT.Vertex[VInfo.Parent];
+ NodePtr VAncestor = DT.Vertex[VInfo.Parent];
// Process Ancestor first
if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) {
@@ -128,8 +130,8 @@ typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT,
continue;
auto &VAInfo = DT.Info[VAncestor];
- typename GraphT::NodeRef VAncestorLabel = VAInfo.Label;
- typename GraphT::NodeRef VLabel = VInfo.Label;
+ NodePtr VAncestorLabel = VAInfo.Label;
+ NodePtr VLabel = VInfo.Label;
if (DT.Info[VAncestorLabel].Semi < DT.Info[VLabel].Semi)
VInfo.Label = VAncestorLabel;
VInfo.Parent = VAInfo.Parent;
@@ -141,10 +143,11 @@ typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT,
template <class FuncT, class NodeT>
void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
FuncT &F) {
- typedef GraphTraits<NodeT> GraphT;
- static_assert(std::is_pointer<typename GraphT::NodeRef>::value,
+ using GraphT = GraphTraits<NodeT>;
+ using NodePtr = typename GraphT::NodeRef;
+ static_assert(std::is_pointer<NodePtr>::value,
"NodeRef should be pointer type");
- typedef typename std::remove_pointer<typename GraphT::NodeRef>::type NodeType;
+ using NodeType = typename std::remove_pointer<NodePtr>::type;
unsigned N = 0;
bool MultipleRoots = (DT.Roots.size() > 1);
@@ -186,13 +189,13 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
Buckets[i] = i;
for (unsigned i = N; i >= 2; --i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
+ NodePtr W = DT.Vertex[i];
auto &WInfo = DT.Info[W];
// Step #2: Implicitly define the immediate dominator of vertices
for (unsigned j = i; Buckets[j] != i; j = Buckets[j]) {
- typename GraphT::NodeRef V = DT.Vertex[Buckets[j]];
- typename GraphT::NodeRef U = Eval<GraphT>(DT, V, i + 1);
+ NodePtr V = DT.Vertex[Buckets[j]];
+ NodePtr U = Eval<GraphT>(DT, V, i + 1);
DT.IDoms[V] = DT.Info[U].Semi < i ? U : W;
}
@@ -219,17 +222,17 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
}
if (N >= 1) {
- typename GraphT::NodeRef Root = DT.Vertex[1];
+ NodePtr Root = DT.Vertex[1];
for (unsigned j = 1; Buckets[j] != 1; j = Buckets[j]) {
- typename GraphT::NodeRef V = DT.Vertex[Buckets[j]];
+ NodePtr V = DT.Vertex[Buckets[j]];
DT.IDoms[V] = Root;
}
}
// Step #4: Explicitly define the immediate dominator of each vertex
for (unsigned i = 2; i <= N; ++i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
- typename GraphT::NodeRef &WIDom = DT.IDoms[W];
+ NodePtr W = DT.Vertex[i];
+ NodePtr &WIDom = DT.IDoms[W];
if (WIDom != DT.Vertex[DT.Info[W].Semi])
WIDom = DT.IDoms[WIDom];
}
@@ -240,7 +243,7 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
// one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
// which postdominates all real exits if there are multiple exit blocks, or
// an infinite loop.
- typename GraphT::NodeRef Root = !MultipleRoots ? DT.Roots[0] : nullptr;
+ NodePtr Root = !MultipleRoots ? DT.Roots[0] : nullptr;
DT.RootNode =
(DT.DomTreeNodes[Root] =
@@ -249,13 +252,13 @@ void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
// Loop over all of the reachable blocks in the function...
for (unsigned i = 2; i <= N; ++i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
+ NodePtr W = DT.Vertex[i];
// Don't replace this with 'count', the insertion side effect is important
if (DT.DomTreeNodes[W])
continue; // Haven't calculated this node yet?
- ty