Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
LowerTypeTests.cpp File Reference
#include "llvm/Transforms/IPO/LowerTypeTests.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/TypeMetadataUtils.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/ModuleSummaryIndexYAML.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/ReplaceConstant.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Use.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TrailingObjects.h"
#include "llvm/Support/YAMLTraits.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <memory>
#include <set>
#include <string>
#include <system_error>
#include <utility>
#include <vector>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "lowertypetests"

Functions

 STATISTIC (ByteArraySizeBits, "Byte array size in bits")
 STATISTIC (ByteArraySizeBytes, "Byte array size in bytes")
 STATISTIC (NumByteArraysCreated, "Number of byte arrays created")
 STATISTIC (NumTypeTestCallsLowered, "Number of type test calls lowered")
 STATISTIC (NumTypeIdDisjointSets, "Number of disjoint sets of type identifiers")
static BitSetInfo buildBitSet (ArrayRef< uint64_t > Offsets)
 Build a bit set for list of offsets.
static ValuecreateMaskedBitTest (IRBuilder<> &B, Value *Bits, Value *BitOffset)
 Build a test that bit BitOffset mod sizeof(Bits)*8 is set in Bits.
static bool isKnownTypeIdMember (Metadata *TypeId, const DataLayout &DL, Value *V, uint64_t COffset)
static auto buildBitSets (ArrayRef< Metadata * > TypeIds, const DenseMap< GlobalTypeMember *, uint64_t > &GlobalLayout)
static bool isThumbFunction (Function *F, Triple::ArchType ModuleArch)
static bool isDirectCall (Use &U)
static void dropTypeTests (Module &M, Function &TypeTestFunc, bool ShouldDropAll)

Variables

static cl::opt< boolAvoidReuse ("lowertypetests-avoid-reuse", cl::desc("Try to avoid reuse of byte array addresses using aliases"), cl::Hidden, cl::init(true))
static cl::opt< PassSummaryActionClSummaryAction ("lowertypetests-summary-action", cl::desc("What to do with the summary when running this pass"), cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"), clEnumValN(PassSummaryAction::Import, "import", "Import typeid resolutions from summary and globals"), clEnumValN(PassSummaryAction::Export, "export", "Export typeid resolutions to summary and globals")), cl::Hidden)
static cl::opt< std::stringClReadSummary ("lowertypetests-read-summary", cl::desc("Read summary from given YAML file before running pass"), cl::Hidden)
static cl::opt< std::stringClWriteSummary ("lowertypetests-write-summary", cl::desc("Write summary to given YAML file after running pass"), cl::Hidden)
static cl::opt< DropTestKindClDropTypeTests ("lowertypetests-drop-type-tests", cl::desc("Simply drop type test sequences"), cl::values(clEnumValN(DropTestKind::None, "none", "Do not drop any type tests"), clEnumValN(DropTestKind::Assume, "assume", "Drop type test assume sequences"), clEnumValN(DropTestKind::All, "all", "Drop all type test sequences")), cl::Hidden, cl::init(DropTestKind::None))
static const unsigned kX86JumpTableEntrySize = 8
static const unsigned kX86IBTJumpTableEntrySize = 16
static const unsigned kARMJumpTableEntrySize = 4
static const unsigned kARMBTIJumpTableEntrySize = 8
static const unsigned kARMv6MJumpTableEntrySize = 16
static const unsigned kRISCVJumpTableEntrySize = 8
static const unsigned kLOONGARCH64JumpTableEntrySize = 8

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lowertypetests"

Definition at line 91 of file LowerTypeTests.cpp.

Function Documentation

◆ buildBitSet()

BitSetInfo buildBitSet ( ArrayRef< uint64_t > Offsets)
static

Build a bit set for list of offsets.

Definition at line 577 of file LowerTypeTests.cpp.

References llvm::lowertypetests::BitSetBuilder::build().

Referenced by buildBitSets().

◆ buildBitSets()

◆ createMaskedBitTest()

Value * createMaskedBitTest ( IRBuilder<> & B,
Value * Bits,
Value * BitOffset )
static

Build a test that bit BitOffset mod sizeof(Bits)*8 is set in Bits.

This pattern matches to the bt instruction on x86.

Definition at line 585 of file LowerTypeTests.cpp.

References B(), llvm::BitWidth, and llvm::cast().

◆ dropTypeTests()

◆ isDirectCall()

bool isDirectCall ( Use & U)
static

Definition at line 1947 of file LowerTypeTests.cpp.

References llvm::dyn_cast().

◆ isKnownTypeIdMember()

bool isKnownTypeIdMember ( Metadata * TypeId,
const DataLayout & DL,
Value * V,
uint64_t COffset )
static

◆ isThumbFunction()

◆ STATISTIC() [1/5]

STATISTIC ( ByteArraySizeBits ,
"Byte array size in bits"  )

◆ STATISTIC() [2/5]

STATISTIC ( ByteArraySizeBytes ,
"Byte array size in bytes"  )

◆ STATISTIC() [3/5]

STATISTIC ( NumByteArraysCreated ,
"Number of byte arrays created"  )

◆ STATISTIC() [4/5]

STATISTIC ( NumTypeIdDisjointSets ,
"Number of disjoint sets of type identifiers"  )

◆ STATISTIC() [5/5]

STATISTIC ( NumTypeTestCallsLowered ,
"Number of type test calls lowered"  )

Variable Documentation

◆ AvoidReuse

cl::opt< bool > AvoidReuse("lowertypetests-avoid-reuse", cl::desc("Try to avoid reuse of byte array addresses using aliases"), cl::Hidden, cl::init(true)) ( "lowertypetests-avoid-reuse" ,
cl::desc("Try to avoid reuse of byte array addresses using aliases") ,
cl::Hidden ,
cl::init(true)  )
static

◆ ClDropTypeTests

cl::opt< DropTestKind > ClDropTypeTests("lowertypetests-drop-type-tests", cl::desc("Simply drop type test sequences"), cl::values(clEnumValN(DropTestKind::None, "none", "Do not drop any type tests"), clEnumValN(DropTestKind::Assume, "assume", "Drop type test assume sequences"), clEnumValN(DropTestKind::All, "all", "Drop all type test sequences")), cl::Hidden, cl::init(DropTestKind::None)) ( "lowertypetests-drop-type-tests" ,
cl::desc("Simply drop type test sequences") ,
cl::values(clEnumValN(DropTestKind::None, "none", "Do not drop any type tests"), clEnumValN(DropTestKind::Assume, "assume", "Drop type test assume sequences"), clEnumValN(DropTestKind::All, "all", "Drop all type test sequences")) ,
cl::Hidden ,
cl::init(DropTestKind::None)  )
static

◆ ClReadSummary

cl::opt< std::string > ClReadSummary("lowertypetests-read-summary", cl::desc("Read summary from given YAML file before running pass"), cl::Hidden) ( "lowertypetests-read-summary" ,
cl::desc("Read summary from given YAML file before running pass") ,
cl::Hidden  )
static

◆ ClSummaryAction

cl::opt< PassSummaryAction > ClSummaryAction("lowertypetests-summary-action", cl::desc("What to do with the summary when running this pass"), cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"), clEnumValN(PassSummaryAction::Import, "import", "Import typeid resolutions from summary and globals"), clEnumValN(PassSummaryAction::Export, "export", "Export typeid resolutions to summary and globals")), cl::Hidden) ( "lowertypetests-summary-action" ,
cl::desc("What to do with the summary when running this pass") ,
cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"), clEnumValN(PassSummaryAction::Import, "import", "Import typeid resolutions from summary and globals"), clEnumValN(PassSummaryAction::Export, "export", "Export typeid resolutions to summary and globals")) ,
cl::Hidden  )
static

◆ ClWriteSummary

cl::opt< std::string > ClWriteSummary("lowertypetests-write-summary", cl::desc("Write summary to given YAML file after running pass"), cl::Hidden) ( "lowertypetests-write-summary" ,
cl::desc("Write summary to given YAML file after running pass") ,
cl::Hidden  )
static

◆ kARMBTIJumpTableEntrySize

const unsigned kARMBTIJumpTableEntrySize = 8
static

Definition at line 1263 of file LowerTypeTests.cpp.

◆ kARMJumpTableEntrySize

const unsigned kARMJumpTableEntrySize = 4
static

Definition at line 1262 of file LowerTypeTests.cpp.

◆ kARMv6MJumpTableEntrySize

const unsigned kARMv6MJumpTableEntrySize = 16
static

Definition at line 1264 of file LowerTypeTests.cpp.

◆ kLOONGARCH64JumpTableEntrySize

const unsigned kLOONGARCH64JumpTableEntrySize = 8
static

Definition at line 1266 of file LowerTypeTests.cpp.

◆ kRISCVJumpTableEntrySize

const unsigned kRISCVJumpTableEntrySize = 8
static

Definition at line 1265 of file LowerTypeTests.cpp.

◆ kX86IBTJumpTableEntrySize

const unsigned kX86IBTJumpTableEntrySize = 16
static

Definition at line 1261 of file LowerTypeTests.cpp.

◆ kX86JumpTableEntrySize

const unsigned kX86JumpTableEntrySize = 8
static

Definition at line 1260 of file LowerTypeTests.cpp.