ReduceInvokes.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===- ReduceInvokes.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. // Try to replace invokes with calls.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "ReduceInvokes.h"
  13. #include "Delta.h"
  14. #include "llvm/IR/Instructions.h"
  15. #include "llvm/Transforms/Utils/Local.h"
  16. using namespace llvm;
  17. static void reduceInvokesInFunction(Oracle &O, Function &F) {
  18. for (BasicBlock &BB : F) {
  19. InvokeInst *Invoke = dyn_cast<InvokeInst>(BB.getTerminator());
  20. if (Invoke && !O.shouldKeep())
  21. changeToCall(Invoke);
  22. }
  23. // TODO: We most likely are leaving behind dead landingpad blocks. Should we
  24. // delete unreachable blocks now, or leave that for the unreachable block
  25. // reduction.
  26. }
  27. static void reduceInvokesInModule(Oracle &O, ReducerWorkItem &WorkItem) {
  28. for (Function &F : WorkItem.getModule()) {
  29. if (F.hasPersonalityFn())
  30. reduceInvokesInFunction(O, F);
  31. }
  32. }
  33. void llvm::reduceInvokesDeltaPass(TestRunner &Test) {
  34. runDeltaPass(Test, reduceInvokesInModule, "Reducing Invokes");
  35. }