Skip to content

Commit c45e17f

Browse files
[NewPM] Add CrossDSOCFI pass irrespective of LTO optimization level
This pass is not an optimization and is needed for CFI functionality (cross-dso verification). Differential Revision: https://reviews.llvm.org/D106699
1 parent 5d679fc commit c45e17f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,10 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
16471647
// Convert @llvm.global.annotations to !annotation metadata.
16481648
MPM.addPass(Annotation2MetadataPass());
16491649

1650+
// Create a function that performs CFI checks for cross-DSO calls with targets
1651+
// in the current module.
1652+
MPM.addPass(CrossDSOCFIPass());
1653+
16501654
if (Level == OptimizationLevel::O0) {
16511655
// The WPD and LowerTypeTest passes need to run at -O0 to lower type
16521656
// metadata and intrinsics.
@@ -1865,10 +1869,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
18651869
MainFPM.addPass(JumpThreadingPass(/*InsertFreezeWhenUnfoldingSelect*/ true));
18661870
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(MainFPM)));
18671871

1868-
// Create a function that performs CFI checks for cross-DSO calls with
1869-
// targets in the current module.
1870-
MPM.addPass(CrossDSOCFIPass());
1871-
18721872
// Lower type metadata and the type.test intrinsic. This pass supports
18731873
// clang's control flow integrity mechanisms (-fsanitize=cfi*) and needs
18741874
// to be run at link time if CFI is enabled. This pass does nothing if

llvm/test/Other/new-pm-O0-defaults.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
; CHECK-THINLTO-NEXT: Running pass: EliminateAvailableExternallyPass
5454
; CHECK-THINLTO-NEXT: Running pass: GlobalDCEPass
5555
; CHECK-LTO: Running pass: Annotation2MetadataPass
56+
; CHECK-LTO-NEXT: Running pass: CrossDSOCFIPass on [module]
5657
; CHECK-LTO-NEXT: Running pass: WholeProgramDevirtPass
5758
; CHECK-LTO-NEXT: Running analysis: InnerAnalysisManagerProxy
5859
; CHECK-LTO-NEXT: Running pass: LowerTypeTestsPass

llvm/test/Other/new-pm-lto-defaults.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
; RUN: --check-prefix=CHECK-O3 --check-prefix=CHECK-EP-Peephole
2727

2828
; CHECK-O: Running pass: Annotation2Metadata
29+
; CHECK-O-NEXT: Running pass: CrossDSOCFIPass
2930
; CHECK-O-NEXT: Running pass: GlobalDCEPass
3031
; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass
3132
; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass
@@ -123,7 +124,6 @@
123124
; CHECK-O23SZ-NEXT: Running pass: InstCombinePass on foo
124125
; CHECK-EP-Peephole-NEXT: Running pass: NoOpFunctionPass on foo
125126
; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass on foo
126-
; CHECK-O23SZ-NEXT: Running pass: CrossDSOCFIPass
127127
; CHECK-O23SZ-NEXT: Running pass: LowerTypeTestsPass
128128
; CHECK-O-NEXT: Running pass: LowerTypeTestsPass
129129
; CHECK-O23SZ-NEXT: Running pass: SimplifyCFGPass

0 commit comments

Comments
 (0)