/// manager.
ModulePass *createBarrierNoopPass();
-/// What to do with the summary when running the LowerTypeTests pass.
-enum class LowerTypeTestsSummaryAction {
+/// What to do with the summary when running passes that operate on it.
+enum class PassSummaryAction {
None, ///< Do nothing.
- Import, ///< Import typeid resolutions from summary and globals.
- Export, ///< Export typeid resolutions to summary and globals.
+ Import, ///< Import information from summary.
+ Export, ///< Export information to summary.
};
/// \brief This pass lowers type metadata and the llvm.type.test intrinsic to
/// \param Action What to do with the summary passed as Index.
/// \param Index The summary to use for importing or exporting, this can be null
/// when Action is None.
-ModulePass *createLowerTypeTestsPass(LowerTypeTestsSummaryAction Action,
+ModulePass *createLowerTypeTestsPass(PassSummaryAction Action,
ModuleSummaryIndex *Index);
/// \brief This pass export CFI checks for use by external modules.
using namespace llvm;
using namespace lowertypetests;
-using SummaryAction = LowerTypeTestsSummaryAction;
-
#define DEBUG_TYPE "lowertypetests"
STATISTIC(ByteArraySizeBits, "Byte array size in bits");
cl::desc("Try to avoid reuse of byte array addresses using aliases"),
cl::Hidden, cl::init(true));
-static cl::opt<SummaryAction> ClSummaryAction(
+static cl::opt<PassSummaryAction> ClSummaryAction(
"lowertypetests-summary-action",
cl::desc("What to do with the summary when running this pass"),
- cl::values(clEnumValN(SummaryAction::None, "none", "Do nothing"),
- clEnumValN(SummaryAction::Import, "import",
+ cl::values(clEnumValN(PassSummaryAction::None, "none", "Do nothing"),
+ clEnumValN(PassSummaryAction::Import, "import",
"Import typeid resolutions from summary and globals"),
- clEnumValN(SummaryAction::Export, "export",
+ clEnumValN(PassSummaryAction::Export, "export",
"Export typeid resolutions to summary and globals")),
cl::Hidden);
class LowerTypeTestsModule {
Module &M;
- SummaryAction Action;
+ PassSummaryAction Action;
ModuleSummaryIndex *Summary;
bool LinkerSubsectionsViaSymbols;
void createJumpTable(Function *F, ArrayRef<GlobalTypeMember *> Functions);
public:
- LowerTypeTestsModule(Module &M, SummaryAction Action,
+ LowerTypeTestsModule(Module &M, PassSummaryAction Action,
ModuleSummaryIndex *Summary);
bool lower();
bool UseCommandLine = false;
- SummaryAction Action;
+ PassSummaryAction Action;
ModuleSummaryIndex *Summary;
LowerTypeTests() : ModulePass(ID), UseCommandLine(true) {
initializeLowerTypeTestsPass(*PassRegistry::getPassRegistry());
}
- LowerTypeTests(SummaryAction Action, ModuleSummaryIndex *Summary)
+ LowerTypeTests(PassSummaryAction Action, ModuleSummaryIndex *Summary)
: ModulePass(ID), Action(Action), Summary(Summary) {
initializeLowerTypeTestsPass(*PassRegistry::getPassRegistry());
}
false)
char LowerTypeTests::ID = 0;
-ModulePass *llvm::createLowerTypeTestsPass(SummaryAction Action,
+ModulePass *llvm::createLowerTypeTestsPass(PassSummaryAction Action,
ModuleSummaryIndex *Summary) {
return new LowerTypeTests(Action, Summary);
}
} else {
Constant *ByteArray = TIL.TheByteArray;
if (!LinkerSubsectionsViaSymbols && AvoidReuse &&
- Action != SummaryAction::Import) {
+ Action != PassSummaryAction::Import) {
// Each use of the byte array uses a different alias. This makes the
// backend less likely to reuse previously computed byte array addresses,
// improving the security of the CFI mechanism based on this pass.
}
/// Lower all type tests in this module.
-LowerTypeTestsModule::LowerTypeTestsModule(Module &M, SummaryAction Action,
+LowerTypeTestsModule::LowerTypeTestsModule(Module &M, PassSummaryAction Action,
ModuleSummaryIndex *Summary)
: M(M), Action(Action), Summary(Summary) {
Triple TargetTriple(M.getTargetTriple());
Function *TypeTestFunc =
M.getFunction(Intrinsic::getName(Intrinsic::type_test));
if ((!TypeTestFunc || TypeTestFunc->use_empty()) &&
- Action != SummaryAction::Export)
+ Action != PassSummaryAction::Export)
return false;
- if (Action == SummaryAction::Import) {
+ if (Action == PassSummaryAction::Import) {
for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end();
UI != UE;) {
auto *CI = cast<CallInst>((*UI++).getUser());
}
}
- if (Action == SummaryAction::Export) {
+ if (Action == PassSummaryAction::Export) {
DenseMap<GlobalValue::GUID, TinyPtrVector<Metadata *>> MetadataByGUID;
for (auto &P : TypeIdInfo) {
if (auto *TypeId = dyn_cast<MDString>(P.first))
PreservedAnalyses LowerTypeTestsPass::run(Module &M,
ModuleAnalysisManager &AM) {
bool Changed =
- LowerTypeTestsModule(M, SummaryAction::None, /*Summary=*/nullptr).lower();
+ LowerTypeTestsModule(M, PassSummaryAction::None, /*Summary=*/nullptr)
+ .lower();
if (!Changed)
return PreservedAnalyses::all();
return PreservedAnalyses::none();