ReduceAliases.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //===- ReduceAliases.cpp - Specialized Delta Pass -------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file implements a function which calls the Generic Delta pass in order
  10. // to reduce aliases in the provided Module.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "ReduceAliases.h"
  14. #include "Delta.h"
  15. #include "llvm/IR/Constants.h"
  16. #include "llvm/IR/GlobalValue.h"
  17. using namespace llvm;
  18. /// Removes all aliases aren't inside any of the
  19. /// desired Chunks.
  20. static void extractAliasesFromModule(Oracle &O, Module &Program) {
  21. for (auto &GA : make_early_inc_range(Program.aliases())) {
  22. if (!O.shouldKeep()) {
  23. GA.replaceAllUsesWith(GA.getAliasee());
  24. GA.eraseFromParent();
  25. }
  26. }
  27. }
  28. void llvm::reduceAliasesDeltaPass(TestRunner &Test) {
  29. errs() << "*** Reducing Aliases ...\n";
  30. runDeltaPass(Test, extractAliasesFromModule);
  31. errs() << "----------------------------\n";
  32. }