LLVM: include/llvm/Transforms/Utils/FunctionComparator.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H

15#define LLVM_TRANSFORMS_UTILS_FUNCTIONCOMPARATOR_H

16

25#include

26#include

27

28namespace llvm {

29

31class AttributeList;

42

43

44

45

46

47

48

49

50

51

52

53

54

58 };

59

60

61

62

64 ValueNumberMap GlobalNumbers;

65

66

68

69public:

71

74 bool Inserted;

75 std::tie(MapIter, Inserted) = GlobalNumbers.insert({Global, NextNumber});

76 if (Inserted)

77 NextNumber++;

78 return MapIter->second;

79 }

80

82 GlobalNumbers.erase(Global);

83 }

84

86 GlobalNumbers.clear();

87 }

88};

89

90

91

92

93

95public:

98 : FnL(F1), FnR(F2), GlobalNumbers(GN) {}

99

100

102

103protected:

104

106 sn_mapL.clear();

107 sn_mapR.clear();

108 }

109

110

112

113

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

220

221

222

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

275 bool &needToCmpOperands) const;

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

318

326

327

329

330private:

333 int cmpAttrs(const AttributeList L, const AttributeList R) const;

334 int cmpMDNode(const MDNode *L, const MDNode *R) const;

337 int cmpOperandBundlesSchema(const CallBase &LCS, const CallBase &RCS) const;

338

339

340

341

342

343

344

345

346

351 }

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

387

388

390};

391

392}

393

394#endif

Atomic ordering constants.

This file defines the DenseMap class.

Class for arbitrary precision integers.

LLVM Basic Block Representation.

Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...

This class represents a range of values.

This is an important base class in LLVM.

FunctionComparator(const Function *F1, const Function *F2, GlobalNumberState *GN)

Definition FunctionComparator.h:96

LLVM_ABI int cmpBasicBlocks(const BasicBlock *BBL, const BasicBlock *BBR) const

Test whether two basic blocks have equivalent behaviour.

const Function * FnR

Definition FunctionComparator.h:328

LLVM_ABI int cmpConstantRanges(const ConstantRange &L, const ConstantRange &R) const

LLVM_ABI int compareSignature() const

Compares the signature and other general attributes of the two functions.

LLVM_ABI int cmpMem(StringRef L, StringRef R) const

LLVM_ABI int compare()

Test whether the two functions have equivalent behaviour.

LLVM_ABI int cmpAPFloats(const APFloat &L, const APFloat &R) const

const Function * FnL

Definition FunctionComparator.h:328

LLVM_ABI int cmpTypes(Type *TyL, Type *TyR) const

cmpType - compares two types, defines total ordering among the types set.

LLVM_ABI int cmpOperations(const Instruction *L, const Instruction *R, bool &needToCmpOperands) const

Compare two Instructions for equivalence, similar to Instruction::isSameOperationAs.

LLVM_ABI int cmpNumbers(uint64_t L, uint64_t R) const

LLVM_ABI int cmpAligns(Align L, Align R) const

void beginCompare()

Start the comparison.

Definition FunctionComparator.h:105

LLVM_ABI int cmpValues(const Value *L, const Value *R) const

Assign or look up previously assigned numbers for the two values, and return whether the numbers are ...

LLVM_ABI int cmpGlobalValues(GlobalValue *L, GlobalValue *R) const

Compares two global values by number.

LLVM_ABI int cmpConstants(const Constant *L, const Constant *R) const

Constants comparison.

LLVM_ABI int cmpAPInts(const APInt &L, const APInt &R) const

an instruction for type-safe pointer arithmetic to access elements of arrays and structs

GlobalNumberState assigns an integer to each global value in the program, which is used by the compar...

Definition FunctionComparator.h:55

GlobalNumberState()=default

void clear()

Definition FunctionComparator.h:85

void erase(GlobalValue *Global)

Definition FunctionComparator.h:81

uint64_t getNumber(GlobalValue *Global)

Definition FunctionComparator.h:72

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

The instances of the Type class are immutable: once they are created, they are never changed.

ValueMapIteratorImpl< MapT, GlobalValue *, false > iterator

LLVM Value Representation.

This is an optimization pass for GlobalISel generic memory operations.

@ Global

Append to llvm.global_dtors.

AtomicOrdering

Atomic ordering for LLVM's memory model.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

This struct is a compact representation of a valid (non-zero power of two) alignment.

This class defines the default behavior for configurable aspects of ValueMap<>.

std::conditional_t< IsConst, const ValueT &, ValueT & > second