It's okay to call this function even if the module has been materialized.
| 1145 | |
| 1146 | // It's okay to call this function even if the module has been materialized. |
| 1147 | Status LlvmCodeGen::FinalizeLazyMaterialization() { |
| 1148 | for (llvm::Function& fn : module_->functions()) { |
| 1149 | if (fn.isMaterializable()) { |
| 1150 | DCHECK(!module_->isMaterialized()); |
| 1151 | // Unmaterialized functions can still have their declarations around. LLVM asserts |
| 1152 | // these unmaterialized functions' linkage types are external / external weak. |
| 1153 | fn.setLinkage(llvm::Function::ExternalLinkage); |
| 1154 | // DCE may claim the personality function is still referenced by unmaterialized |
| 1155 | // functions when it is deleted by DCE. Similarly, LLVM may complain if comdats |
| 1156 | // reference unmaterialized functions but their definition cannot be found. |
| 1157 | // Since the unmaterialized functions are not used anyway, just remove their |
| 1158 | // personality functions and comdats. |
| 1159 | fn.setPersonalityFn(NULL); |
| 1160 | fn.setComdat(NULL); |
| 1161 | fn.setIsMaterializable(false); |
| 1162 | } |
| 1163 | } |
| 1164 | // All unused functions are now not materializable so it should be quick to call |
| 1165 | // materializeAll(). We need to call this function in order to destroy the |
| 1166 | // materializer so that DCE will not assert fail. |
| 1167 | return MaterializeModule(); |
| 1168 | } |
| 1169 | |
| 1170 | bool LlvmCodeGen::LookupCache(CodeGenCacheKey& cache_key) { |
| 1171 | DCHECK(!cache_key.empty()); |