llvm.org GIT mirror llvm / 0dd611b
[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 Davide Italiano 4 years ago
5 changed file(s) with 41 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 //===-- CrossDSOCFI.cpp - Externalize this module's CFI checks --*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This pass exports all llvm.bitset's found in the module in the form of a
10 // __cfi_check function, which can be used to verify cross-DSO call targets.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
15 #define LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
16
17 #include "llvm/IR/Module.h"
18 #include "llvm/IR/PassManager.h"
19
20 namespace llvm {
21 class CrossDSOCFIPass : public PassInfoMixin {
22 public:
23 PreservedAnalyses run(Module &M, AnalysisManager &AM);
24 };
25 }
26 #endif // LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
27
5656 #include "llvm/Target/TargetMachine.h"
5757 #include "llvm/Transforms/GCOVProfiler.h"
5858 #include "llvm/Transforms/IPO/ConstantMerge.h"
59 #include "llvm/Transforms/IPO/CrossDSOCFI.h"
5960 #include "llvm/Transforms/IPO/DeadArgumentElimination.h"
6061 #include "llvm/Transforms/IPO/ElimAvailExtern.h"
6162 #include "llvm/Transforms/IPO/ForceFunctionAttrs.h"
3737 #define MODULE_PASS(NAME, CREATE_PASS)
3838 #endif
3939 MODULE_PASS("constmerge", ConstantMergePass())
40 MODULE_PASS("cross-dso-cfi", CrossDSOCFIPass())
4041 MODULE_PASS("deadargelim", DeadArgumentEliminationPass())
4142 MODULE_PASS("elim-avail-extern", EliminateAvailableExternallyPass())
4243 MODULE_PASS("forceattrs", ForceFunctionAttrsPass())
1111 //
1212 //===----------------------------------------------------------------------===//
1313
14 #include "llvm/Transforms/IPO.h"
14 #include "llvm/Transforms/IPO/CrossDSOCFI.h"
1515 #include "llvm/ADT/DenseSet.h"
1616 #include "llvm/ADT/EquivalenceClasses.h"
1717 #include "llvm/ADT/Statistic.h"
2929 #include "llvm/Pass.h"
3030 #include "llvm/Support/Debug.h"
3131 #include "llvm/Support/raw_ostream.h"
32 #include "llvm/Transforms/IPO.h"
3233 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
3334
3435 using namespace llvm;
152153 buildCFICheck(M);
153154 return true;
154155 }
156
157 PreservedAnalyses CrossDSOCFIPass::run(Module &M, AnalysisManager &AM) {
158 CrossDSOCFI Impl;
159 bool Changed = Impl.runOnModule(M);
160 if (!Changed)
161 return PreservedAnalyses::all();
162 return PreservedAnalyses::none();
163 }
0 ; RUN: opt -S -cross-dso-cfi < %s | FileCheck %s
1 ; RUN: opt -S -passes=cross-dso-cfi < %s | FileCheck %s
12
23 ; CHECK: define void @__cfi_check(i64 %[[TYPE:.*]], i8* %[[ADDR:.*]], i8* %[[DATA:.*]]) align 4096
34 ; CHECK: switch i64 %[[TYPE]], label %[[FAIL:.*]] [