LLVM: include/llvm/LTO/legacy/LTOModule.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13#ifndef LLVM_LTO_LEGACY_LTOMODULE_H

14#define LLVM_LTO_LEGACY_LTOMODULE_H

15

25#include

26#include

27

28

29namespace llvm {

35

36

37

38

39struct LTOModule {

40private:

41 struct NameAndAttributes {

46 };

47

48 std::unique_ptr OwnedContext;

49

50 std::string LinkerOpts;

51

52 std::unique_ptr Mod;

55 std::unique_ptr _target;

56 std::vector _symbols;

57

58

61 std::vector _asm_undefines;

62

63 LTOModule(std::unique_ptr M, MemoryBufferRef MBRef,

65

66public:

68

69

72

73

75

76

77

80

81

82

83

85

86

87 LLVM_ABI static std::unique_ptr

89

90

91

92

93

94

95

96

97

106 size_t map_size, off_t offset,

115

118

119 std::unique_ptr takeModule() { return std::move(Mod); }

120

121

123

124

126

127

129 return _symbols.size();

130 }

131

132

134 if (index < _symbols.size())

137 }

138

139

141 if (index < _symbols.size())

142 return _symbols[index].name;

144 }

145

147

149 if (index < _asm_undefines.size())

150 return _asm_undefines[index];

152 }

153

155 if (index < _symbols.size())

156 return _symbols[index].symbol;

157 return nullptr;

158 }

159

161

163

165 size_t buffer_size,

166 const char *path,

167 std::string &out_error);

168

170

172 size_t index, size_t *size);

173

175

177

178

179

181

182private:

183

184

185

187

188

189

190 void parseSymbols();

191

192

194 bool isFunc);

195

196

199

200

203

204

207

208

210

211

212 void addAsmGlobalSymbolUndef(StringRef);

213

214

216

217

219

220

222

223

224 bool objcClassNameFromExpression(const Constant *c, std::string &name);

225

226

229 LLVMContext &Context, bool ShouldBeLazy);

230};

231}

232#endif

This file defines the StringMap class.

Module.h This file contains the declarations for the Module class.

static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash, uint32_t &Attributes)

Parse Input that contains metadata.

static bool isFunction(SDValue Op)

StringSet - A set-like wrapper for the StringMap.

This is an important base class in LLVM.

Represents either an error or a value T.

Tagged union holding either a T or a Error.

This is an important class for using LLVM in a threaded context.

This interface provides simple read-only access to a block of memory, and provides simple methods for...

PointerUnion< GlobalValue *, AsmSymbol * > Symbol

A Module instance is used to store all the information related to an LLVM module.

const Triple & getTargetTriple() const

Get the target triple which is a string describing the target host.

void setTargetTriple(Triple T)

Set the target triple.

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

StringRef - Represent a constant reference to a string, i.e.

StringSet - A wrapper for StringMap that provides set-like functionality.

Primary interface to the complete machine description for the target machine.

Triple - Helper class for working with autoconf configuration names.

LLVM Value Representation.

This is an optimization pass for GlobalISel generic memory operations.

auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)

Get the size of a range.

StringRef getSymbolName(uint32_t index)

Get the name of the symbol at the specified index.

Definition LTOModule.h:140

const GlobalValue * getSymbolGV(uint32_t index)

Definition LTOModule.h:154

static LLVM_ABI ErrorOr< std::unique_ptr< LTOModule > > createFromFile(LLVMContext &Context, StringRef path, const TargetOptions &options)

Create an LTOModule.

static LLVM_ABI bool isBitcodeFile(const void *mem, size_t length)

Returns 'true' if the file or memory contents is LLVM bitcode.

LLVM_ABI Expected< uint32_t > getMachOCPUType() const

static LLVM_ABI std::unique_ptr< MemoryBuffer > makeBuffer(const void *mem, size_t length, StringRef name="")

Create a MemoryBuffer from a memory range with an optional name.

uint32_t getSymbolCount()

Get the number of symbols.

Definition LTOModule.h:128

static LLVM_ABI size_t getDependentLibraryCount(lto::InputFile *input)

uint32_t getAsmUndefSymbolCount()

Definition LTOModule.h:146

Module & getModule()

Definition LTOModule.h:117

LLVM_ABI bool hasCtorDtor() const

Returns true if the module has either the @llvm.global_ctors or the @llvm.global_dtors symbol.

static LLVM_ABI const char * getDependentLibrary(lto::InputFile *input, size_t index, size_t *size)

lto_symbol_attributes getSymbolAttributes(uint32_t index)

Get the attributes for a symbol at the specified index.

Definition LTOModule.h:133

const Module & getModule() const

Definition LTOModule.h:116

static LLVM_ABI ErrorOr< std::unique_ptr< LTOModule > > createFromOpenFileSlice(LLVMContext &Context, int fd, StringRef path, size_t map_size, off_t offset, const TargetOptions &options)

StringRef getLinkerOpts()

Definition LTOModule.h:160

static LLVM_ABI std::string getProducerString(MemoryBuffer *Buffer)

Returns a string representing the producer identification stored in the bitcode, or "" if the bitcode...

const std::vector< StringRef > & getAsmUndefinedRefs()

Definition LTOModule.h:162

static LLVM_ABI bool isBitcodeForTarget(MemoryBuffer *memBuffer, StringRef triplePrefix)

Returns 'true' if the memory buffer is LLVM bitcode for the specified triple.

LLVM_ABI bool isThinLTO()

Returns 'true' if the Module is produced for ThinLTO.

void setTargetTriple(Triple T)

Set the Module's target triple.

Definition LTOModule.h:125

static LLVM_ABI ErrorOr< std::unique_ptr< LTOModule > > createFromOpenFile(LLVMContext &Context, int fd, StringRef path, size_t size, const TargetOptions &options)

static LLVM_ABI ErrorOr< std::unique_ptr< LTOModule > > createInLocalContext(std::unique_ptr< LLVMContext > Context, const void *mem, size_t length, const TargetOptions &options, StringRef path)

static LLVM_ABI ErrorOr< std::unique_ptr< LTOModule > > createFromBuffer(LLVMContext &Context, const void *mem, size_t length, const TargetOptions &options, StringRef path="")

LLVM_ABI Expected< uint32_t > getMachOCPUSubType() const

std::unique_ptr< Module > takeModule()

Definition LTOModule.h:119

const Triple & getTargetTriple()

Return the Module's target triple.

Definition LTOModule.h:122

static LLVM_ABI lto::InputFile * createInputFile(const void *buffer, size_t buffer_size, const char *path, std::string &out_error)

StringRef getAsmUndefSymbolName(uint32_t index)

Definition LTOModule.h:148