Recommit [NFC] Better encapsulation of llvm::Optional Storage
[llvm-complete.git] / include / llvm / Analysis / TypeMetadataUtils.h
blob82cf8efeea54b663e77eb87d3c74f2f673be5429
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ANALYSIS_TYPEMETADATAUTILS_H
15 #define LLVM_ANALYSIS_TYPEMETADATAUTILS_H
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/IR/CallSite.h"
20 namespace llvm {
22 class DominatorTree;
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
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;
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);
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);
55 #endif