]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/include/llvm/Analysis/TypeMetadataUtils.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / include / llvm / Analysis / TypeMetadataUtils.h
1 //===- TypeMetadataUtils.h - Utilities related to type metadata --*- C++ -*-==//
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 contains functions that make it easier to manipulate type metadata
10 // for devirtualization.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_TYPEMETADATAUTILS_H
15 #define LLVM_ANALYSIS_TYPEMETADATAUTILS_H
16
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/IR/CallSite.h"
19
20 namespace llvm {
21
22 class DominatorTree;
23
24 /// The type of CFI jumptable needed for a function.
25 enum CfiFunctionLinkage {
26   CFL_Definition = 0,
27   CFL_Declaration = 1,
28   CFL_WeakDeclaration = 2
29 };
30
31 /// A call site that could be devirtualized.
32 struct DevirtCallSite {
33   /// The offset from the address point to the virtual function.
34   uint64_t Offset;
35   /// The call site itself.
36   CallSite CS;
37 };
38
39 /// Given a call to the intrinsic \@llvm.type.test, find all devirtualizable
40 /// call sites based on the call and return them in DevirtCalls.
41 void findDevirtualizableCallsForTypeTest(
42     SmallVectorImpl<DevirtCallSite> &DevirtCalls,
43     SmallVectorImpl<CallInst *> &Assumes, const CallInst *CI,
44     DominatorTree &DT);
45
46 /// Given a call to the intrinsic \@llvm.type.checked.load, find all
47 /// devirtualizable call sites based on the call and return them in DevirtCalls.
48 void findDevirtualizableCallsForTypeCheckedLoad(
49     SmallVectorImpl<DevirtCallSite> &DevirtCalls,
50     SmallVectorImpl<Instruction *> &LoadedPtrs,
51     SmallVectorImpl<Instruction *> &Preds, bool &HasNonCallUses,
52     const CallInst *CI, DominatorTree &DT);
53
54 Constant *getPointerAtOffset(Constant *I, uint64_t Offset, Module &M);
55 }
56
57 #endif