| OLD | NEW |
| 1 //===- FlattenGlobals.cpp - Flatten global variable initializers-----------===// | 1 //===- FlattenGlobals.cpp - Flatten global variable initializers-----------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This pass converts initializers for global variables into a | 10 // This pass converts initializers for global variables into a |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 uint8_t *BufEnd; | 168 uint8_t *BufEnd; |
| 169 | 169 |
| 170 // 2) an array of relocations. | 170 // 2) an array of relocations. |
| 171 class Reloc { | 171 class Reloc { |
| 172 private: | 172 private: |
| 173 unsigned RelOffset; // Offset at which the relocation is to be applied. | 173 unsigned RelOffset; // Offset at which the relocation is to be applied. |
| 174 RelocUserType *RelocUser; | 174 RelocUserType *RelocUser; |
| 175 public: | 175 public: |
| 176 | 176 |
| 177 unsigned getRelOffset() const { return RelOffset; } | 177 unsigned getRelOffset() const { return RelOffset; } |
| 178 Constant *getRelocUse() const { return ::getRelocUseConstant(RelocUser); } | 178 Constant *getRelocUse() const { return getRelocUseConstant(RelocUser); } |
| 179 Reloc(FlattenGlobalsState &State, unsigned RelOffset, Constant *NewVal) | 179 Reloc(FlattenGlobalsState &State, unsigned RelOffset, Constant *NewVal) |
| 180 : RelOffset(RelOffset), RelocUser(State.getRelocUserHandle(NewVal)) {} | 180 : RelOffset(RelOffset), RelocUser(State.getRelocUserHandle(NewVal)) {} |
| 181 | 181 |
| 182 explicit Reloc(const Reloc &R) | 182 explicit Reloc(const Reloc &R) |
| 183 : RelOffset(R.RelOffset), RelocUser(R.RelocUser) {} | 183 : RelOffset(R.RelOffset), RelocUser(R.RelocUser) {} |
| 184 | 184 |
| 185 void operator=(const Reloc &R) { | 185 void operator=(const Reloc &R) { |
| 186 RelOffset = R.RelOffset; | 186 RelOffset = R.RelOffset; |
| 187 RelocUser = R.RelocUser; | 187 RelocUser = R.RelocUser; |
| 188 } | 188 } |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 State.flattenGlobalsWithInitializers(); | 537 State.flattenGlobalsWithInitializers(); |
| 538 State.removeDeadInitializerConstants(); | 538 State.removeDeadInitializerConstants(); |
| 539 State.replaceGlobalsWithFlattenedGlobals(); | 539 State.replaceGlobalsWithFlattenedGlobals(); |
| 540 State.installFlattenedGlobalInitializers(); | 540 State.installFlattenedGlobalInitializers(); |
| 541 return State.Modified; | 541 return State.Modified; |
| 542 } | 542 } |
| 543 | 543 |
| 544 ModulePass *llvm::createFlattenGlobalsPass() { | 544 ModulePass *llvm::createFlattenGlobalsPass() { |
| 545 return new FlattenGlobals(); | 545 return new FlattenGlobals(); |
| 546 } | 546 } |
| OLD | NEW |