1 //===- TypeMetadataUtils.h - Utilities related to type metadata --*- C++ -*-==//
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
7 //===----------------------------------------------------------------------===//
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"
24 /// The type of CFI jumptable needed for a function.
25 enum CfiFunctionLinkage
{
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.
35 /// The call site itself.
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
,
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
);