• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LIBLLVMBACKEND_TRANSFORMS_PASSES_DEVIRT_PASS_H
17 #define LIBLLVMBACKEND_TRANSFORMS_PASSES_DEVIRT_PASS_H
18 
19 #include <unordered_map>
20 
21 #include "llvm_ark_interface.h"
22 
23 #include <llvm/IR/Intrinsics.h>
24 #include <llvm/IR/PassManager.h>
25 
26 namespace ark::llvmbackend {
27 struct LLVMCompilerOptions;
28 }  // namespace ark::llvmbackend
29 
30 namespace llvm {
31 class CallInst;
32 class Instruction;
33 }  // namespace llvm
34 
35 namespace ark::llvmbackend::passes {
36 
37 class Devirt : public llvm::PassInfoMixin<Devirt> {
38 public:
39     explicit Devirt(LLVMArkInterface *arkInterface = nullptr);
40 
41     static bool ShouldInsert(const ark::llvmbackend::LLVMCompilerOptions *options);
42 
43     static Devirt Create(LLVMArkInterface *arkInterface, const ark::llvmbackend::LLVMCompilerOptions *options);
44 
45     // NOLINTNEXTLINE(readability-identifier-naming)
46     llvm::PreservedAnalyses run(llvm::Function &function, llvm::FunctionAnalysisManager &analysisManager);
47 
48 private:
49     LLVMArkInterface *arkInterface_;
50 
51 public:
52     static constexpr llvm::StringRef ARG_NAME = "devirt";
53 };
54 
55 }  // namespace ark::llvmbackend::passes
56 
57 #endif  // LIBLLVMBACKEND_TRANSFORMS_PASSES_DEVIRT_PASS_H
58