| 1 | //===- LowerIFunc.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 | // |
| 9 | // This file implements replacing calls to ifuncs by introducing indirect calls. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/Transforms/Utils/LowerIFunc.h" |
| 14 | #include "llvm/IR/Module.h" |
| 15 | #include "llvm/Pass.h" |
| 16 | #include "llvm/Transforms/Utils/ModuleUtils.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | /// Replace all call users of ifuncs in the module. |
| 21 | PreservedAnalyses LowerIFuncPass::run(Module &M, ModuleAnalysisManager &AM) { |
| 22 | if (M.ifunc_empty()) |
| 23 | return PreservedAnalyses::all(); |
| 24 | |
| 25 | lowerGlobalIFuncUsersAsGlobalCtor(M, IFuncsToLower: {}); |
| 26 | return PreservedAnalyses::none(); |
| 27 | } |
| 28 |