1 //===- TypeMetadataUtils.h - Utilities related to type metadata --*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains functions that make it easier to manipulate type metadata
11 // for devirtualization.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_ANALYSIS_TYPEMETADATAUTILS_H
16 #define LLVM_ANALYSIS_TYPEMETADATAUTILS_H
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/IR/CallSite.h"
25 /// The type of CFI jumptable needed for a function.
26 enum CfiFunctionLinkage {
29 CFL_WeakDeclaration = 2
32 /// A call site that could be devirtualized.
33 struct DevirtCallSite {
34 /// The offset from the address point to the virtual function.
36 /// The call site itself.
40 /// Given a call to the intrinsic \@llvm.type.test, find all devirtualizable
41 /// call sites based on the call and return them in DevirtCalls.
42 void findDevirtualizableCallsForTypeTest(
43 SmallVectorImpl<DevirtCallSite> &DevirtCalls,
44 SmallVectorImpl<CallInst *> &Assumes, const CallInst *CI,
47 /// Given a call to the intrinsic \@llvm.type.checked.load, find all
48 /// devirtualizable call sites based on the call and return them in DevirtCalls.
49 void findDevirtualizableCallsForTypeCheckedLoad(
50 SmallVectorImpl<DevirtCallSite> &DevirtCalls,
51 SmallVectorImpl<Instruction *> &LoadedPtrs,
52 SmallVectorImpl<Instruction *> &Preds, bool &HasNonCallUses,
53 const CallInst *CI, DominatorTree &DT);