[PM] Port CrossDSOCFI to the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2016-07-09 03:25:35 +00:00
parent d0506b50b4
commit 0dd611bd69
5 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,28 @@
//===-- CrossDSOCFI.cpp - Externalize this module's CFI checks --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This pass exports all llvm.bitset's found in the module in the form of a
// __cfi_check function, which can be used to verify cross-DSO call targets.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
#define LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
namespace llvm {
class CrossDSOCFIPass : public PassInfoMixin<CrossDSOCFIPass> {
public:
PreservedAnalyses run(Module &M, AnalysisManager<Module> &AM);
};
}
#endif // LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H

View File

@ -57,6 +57,7 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/GCOVProfiler.h"
#include "llvm/Transforms/IPO/ConstantMerge.h"
#include "llvm/Transforms/IPO/CrossDSOCFI.h"
#include "llvm/Transforms/IPO/DeadArgumentElimination.h"
#include "llvm/Transforms/IPO/ElimAvailExtern.h"
#include "llvm/Transforms/IPO/ForceFunctionAttrs.h"

View File

@ -38,6 +38,7 @@ MODULE_ALIAS_ANALYSIS("globals-aa", GlobalsAA())
#define MODULE_PASS(NAME, CREATE_PASS)
#endif
MODULE_PASS("constmerge", ConstantMergePass())
MODULE_PASS("cross-dso-cfi", CrossDSOCFIPass())
MODULE_PASS("deadargelim", DeadArgumentEliminationPass())
MODULE_PASS("elim-avail-extern", EliminateAvailableExternallyPass())
MODULE_PASS("forceattrs", ForceFunctionAttrsPass())

View File

@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/CrossDSOCFI.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/Statistic.h"
@ -30,6 +30,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
using namespace llvm;
@ -153,3 +154,11 @@ bool CrossDSOCFI::runOnModule(Module &M) {
buildCFICheck(M);
return true;
}
PreservedAnalyses CrossDSOCFIPass::run(Module &M, AnalysisManager<Module> &AM) {
CrossDSOCFI Impl;
bool Changed = Impl.runOnModule(M);
if (!Changed)
return PreservedAnalyses::all();
return PreservedAnalyses::none();
}

View File

@ -1,4 +1,5 @@
; RUN: opt -S -cross-dso-cfi < %s | FileCheck %s
; RUN: opt -S -passes=cross-dso-cfi < %s | FileCheck %s
; CHECK: define void @__cfi_check(i64 %[[TYPE:.*]], i8* %[[ADDR:.*]], i8* %[[DATA:.*]]) align 4096
; CHECK: switch i64 %[[TYPE]], label %[[FAIL:.*]] [