ReduceGlobalObjects.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. //===- ReduceGlobalObjects.cpp --------------------------------------------===//
  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. #include "ReduceGlobalObjects.h"
  9. #include "llvm/IR/GlobalObject.h"
  10. using namespace llvm;
  11. static bool shouldReduceSection(GlobalObject &GO) { return GO.hasSection(); }
  12. static bool shouldReduceAlign(GlobalObject &GO) {
  13. return GO.getAlign().hasValue();
  14. }
  15. static void reduceGOs(Oracle &O, Module &Program) {
  16. for (auto &GO : Program.global_objects()) {
  17. if (shouldReduceSection(GO) && !O.shouldKeep())
  18. GO.setSection("");
  19. if (shouldReduceAlign(GO) && !O.shouldKeep())
  20. GO.setAlignment(MaybeAlign());
  21. }
  22. }
  23. void llvm::reduceGlobalObjectsDeltaPass(TestRunner &Test) {
  24. outs() << "*** Reducing GlobalObjects...\n";
  25. runDeltaPass(Test, reduceGOs);
  26. }