diff options
Diffstat (limited to 'include/llvm/Transforms/Utils/FunctionImportUtils.h')
-rw-r--r-- | include/llvm/Transforms/Utils/FunctionImportUtils.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm/Transforms/Utils/FunctionImportUtils.h b/include/llvm/Transforms/Utils/FunctionImportUtils.h index 57b7d0fcd7cc..f18cd92310b4 100644 --- a/include/llvm/Transforms/Utils/FunctionImportUtils.h +++ b/include/llvm/Transforms/Utils/FunctionImportUtils.h @@ -40,9 +40,20 @@ class FunctionImportGlobalProcessing { /// as part of a different backend compilation process. bool HasExportedFunctions = false; + /// Set of llvm.*used values, in order to validate that we don't try + /// to promote any non-renamable values. + SmallPtrSet<GlobalValue *, 8> Used; + /// Check if we should promote the given local value to global scope. bool shouldPromoteLocalToGlobal(const GlobalValue *SGV); +#ifndef NDEBUG + /// Check if the given value is a local that can't be renamed (promoted). + /// Only used in assertion checking, and disabled under NDEBUG since the Used + /// set will not be populated. + bool isNonRenamableLocal(const GlobalValue &GV) const; +#endif + /// Helper methods to check if we are importing from or potentially /// exporting from the current source module. bool isPerformingImport() const { return GlobalsToImport != nullptr; } @@ -82,6 +93,13 @@ public: // may be exported to another backend compilation. if (!GlobalsToImport) HasExportedFunctions = ImportIndex.hasExportedFunctions(M); + +#ifndef NDEBUG + // First collect those in the llvm.used set. + collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ false); + // Next collect those in the llvm.compiler.used set. + collectUsedGlobalVariables(M, Used, /*CompilerUsed*/ true); +#endif } bool run(); |