1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Move EntryExitInstrumentation pass location

This seems to be more of a Clang thing rather than a generic LLVM thing,
so this moves it out of LLVM pipelines and as Clang extension hooks into
LLVM pipelines.

Move the post-inline EEInstrumentation out of the backend pipeline and
into a late pass, similar to other sanitizer passes. It doesn't fit
into the codegen pipeline.

Also fix up EntryExitInstrumentation not running at -O0 under the new
PM. PR49143

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D97608
This commit is contained in:
Arthur Eubanks 2021-02-26 20:06:49 -08:00
parent 2a728dadf5
commit 9edc5021eb
20 changed files with 25 additions and 28 deletions

View File

@ -28,6 +28,8 @@ struct EntryExitInstrumenterPass
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
bool PostInlining; bool PostInlining;
static bool isRequired() { return true; }
}; };
} // namespace llvm } // namespace llvm

View File

@ -864,9 +864,6 @@ void TargetPassConfig::addIRPasses() {
if (getOptLevel() != CodeGenOpt::None && !DisablePartialLibcallInlining) if (getOptLevel() != CodeGenOpt::None && !DisablePartialLibcallInlining)
addPass(createPartiallyInlineLibCallsPass()); addPass(createPartiallyInlineLibCallsPass());
// Instrument function entry and exit, e.g. with calls to mcount().
addPass(createPostInlineEntryExitInstrumenterPass());
// Add scalarization of target's unsupported masked memory intrinsics pass. // Add scalarization of target's unsupported masked memory intrinsics pass.
// the unsupported intrinsic will be replaced with a chain of basic blocks, // the unsupported intrinsic will be replaced with a chain of basic blocks,
// that stores/loads element one-by-one if the appropriate mask bit is set. // that stores/loads element one-by-one if the appropriate mask bit is set.

View File

@ -300,7 +300,6 @@ void PassManagerBuilder::addInitialAliasAnalysisPasses(
void PassManagerBuilder::populateFunctionPassManager( void PassManagerBuilder::populateFunctionPassManager(
legacy::FunctionPassManager &FPM) { legacy::FunctionPassManager &FPM) {
addExtensionsToPM(EP_EarlyAsPossible, FPM); addExtensionsToPM(EP_EarlyAsPossible, FPM);
FPM.add(createEntryExitInstrumenterPass());
// Add LibraryInfo if we have some. // Add LibraryInfo if we have some.
if (LibraryInfo) if (LibraryInfo)

View File

@ -21,7 +21,6 @@
; CHECK-NEXT: Shadow Stack GC Lowering ; CHECK-NEXT: Shadow Stack GC Lowering
; CHECK-NEXT: Lower constant intrinsics ; CHECK-NEXT: Lower constant intrinsics
; CHECK-NEXT: Remove unreachable blocks from the CFG ; CHECK-NEXT: Remove unreachable blocks from the CFG
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics ; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: AArch64 Stack Tagging ; CHECK-NEXT: AArch64 Stack Tagging

View File

@ -56,7 +56,6 @@
; CHECK-NEXT: Constant Hoisting ; CHECK-NEXT: Constant Hoisting
; CHECK-NEXT: Replace intrinsics with calls to vector library ; CHECK-NEXT: Replace intrinsics with calls to vector library
; CHECK-NEXT: Partially inline calls to library functions ; CHECK-NEXT: Partially inline calls to library functions
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics ; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Stack Safety Analysis ; CHECK-NEXT: Stack Safety Analysis

View File

@ -10,7 +10,6 @@
; GCN-O0-NEXT: FunctionPass Manager ; GCN-O0-NEXT: FunctionPass Manager
; GCN-O0-NEXT: Early propagate attributes from kernels to functions ; GCN-O0-NEXT: Early propagate attributes from kernels to functions
; GCN-O0-NEXT: Replace builtin math calls with that native versions. ; GCN-O0-NEXT: Replace builtin math calls with that native versions.
; GCN-O0-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; GCN-O0-NEXT: Pass Arguments: ; GCN-O0-NEXT: Pass Arguments:
; GCN-O0-NEXT: Target Library Information ; GCN-O0-NEXT: Target Library Information
@ -42,7 +41,6 @@
; GCN-O1-NEXT: Basic Alias Analysis (stateless AA impl) ; GCN-O1-NEXT: Basic Alias Analysis (stateless AA impl)
; GCN-O1-NEXT: Function Alias Analysis Results ; GCN-O1-NEXT: Function Alias Analysis Results
; GCN-O1-NEXT: Simplify well-known AMD library calls ; GCN-O1-NEXT: Simplify well-known AMD library calls
; GCN-O1-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; GCN-O1-NEXT: Simplify the CFG ; GCN-O1-NEXT: Simplify the CFG
; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-NEXT: Dominator Tree Construction
; GCN-O1-NEXT: SROA ; GCN-O1-NEXT: SROA
@ -352,7 +350,6 @@
; GCN-O2-NEXT: Basic Alias Analysis (stateless AA impl) ; GCN-O2-NEXT: Basic Alias Analysis (stateless AA impl)
; GCN-O2-NEXT: Function Alias Analysis Results ; GCN-O2-NEXT: Function Alias Analysis Results
; GCN-O2-NEXT: Simplify well-known AMD library calls ; GCN-O2-NEXT: Simplify well-known AMD library calls
; GCN-O2-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; GCN-O2-NEXT: Simplify the CFG ; GCN-O2-NEXT: Simplify the CFG
; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O2-NEXT: Dominator Tree Construction
; GCN-O2-NEXT: SROA ; GCN-O2-NEXT: SROA
@ -707,7 +704,6 @@
; GCN-O3-NEXT: Basic Alias Analysis (stateless AA impl) ; GCN-O3-NEXT: Basic Alias Analysis (stateless AA impl)
; GCN-O3-NEXT: Function Alias Analysis Results ; GCN-O3-NEXT: Function Alias Analysis Results
; GCN-O3-NEXT: Simplify well-known AMD library calls ; GCN-O3-NEXT: Simplify well-known AMD library calls
; GCN-O3-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; GCN-O3-NEXT: Simplify the CFG ; GCN-O3-NEXT: Simplify the CFG
; GCN-O3-NEXT: Dominator Tree Construction ; GCN-O3-NEXT: Dominator Tree Construction
; GCN-O3-NEXT: SROA ; GCN-O3-NEXT: SROA

View File

@ -36,7 +36,6 @@
; CHECK-NEXT: Constant Hoisting ; CHECK-NEXT: Constant Hoisting
; CHECK-NEXT: Replace intrinsics with calls to vector library ; CHECK-NEXT: Replace intrinsics with calls to vector library
; CHECK-NEXT: Partially inline calls to library functions ; CHECK-NEXT: Partially inline calls to library functions
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics ; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Natural Loop Information ; CHECK-NEXT: Natural Loop Information

View File

@ -18,6 +18,7 @@ define dso_local void @callee() #0 {
; CHECK-THUMB-FAST-ISEL-NEXT: bl __gnu_mcount_nc ; CHECK-THUMB-FAST-ISEL-NEXT: bl __gnu_mcount_nc
; CHECK-THUMB-GLOBAL-ISEL: push {lr} ; CHECK-THUMB-GLOBAL-ISEL: push {lr}
; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl __gnu_mcount_nc ; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl __gnu_mcount_nc
call void @llvm.arm.gnu.eabi.mcount()
ret void ret void
} }
@ -34,8 +35,12 @@ define dso_local void @caller() #0 {
; CHECK-THUMB-FAST-ISEL-NEXT: bl __gnu_mcount_nc ; CHECK-THUMB-FAST-ISEL-NEXT: bl __gnu_mcount_nc
; CHECK-THUMB-GLOBAL-ISEL: push {lr} ; CHECK-THUMB-GLOBAL-ISEL: push {lr}
; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl __gnu_mcount_nc ; CHECK-THUMB-GLOBAL-ISEL-NEXT: bl __gnu_mcount_nc
call void @llvm.arm.gnu.eabi.mcount()
call void @callee() call void @callee()
ret void ret void
} }
attributes #0 = { nofree nounwind "instrument-function-entry-inlined"="llvm.arm.gnu.eabi.mcount" } declare void @llvm.arm.gnu.eabi.mcount() #1
attributes #0 = { nofree nounwind }
attributes #1 = { nounwind }

View File

@ -4,9 +4,9 @@
; RUN: llc -march=mips -target-abi o32 --mattr=-long-calls,+noabicalls < %s \ ; RUN: llc -march=mips -target-abi o32 --mattr=-long-calls,+noabicalls < %s \
; RUN: -mips-jalr-reloc=false | FileCheck -check-prefixes=CHECK,SHORT %s ; RUN: -mips-jalr-reloc=false | FileCheck -check-prefixes=CHECK,SHORT %s
; Function Attrs: noinline nounwind optnone define void @foo() {
define void @foo() #0 {
entry: entry:
call void @_mcount()
ret void ret void
; CHECK-LABEL: foo ; CHECK-LABEL: foo
@ -16,4 +16,4 @@ entry:
; SHORT: jal _mcount ; SHORT: jal _mcount
} }
attributes #0 = { "instrument-function-entry-inlined"="_mcount" } declare void @_mcount()

View File

@ -15,8 +15,7 @@
; Test that checks ABI for _mcount calls. ; Test that checks ABI for _mcount calls.
; Function Attrs: noinline nounwind optnone define void @foo() {
define void @foo() #0 {
; MIPS32-LABEL: foo: ; MIPS32-LABEL: foo:
; MIPS32: # %bb.0: # %entry ; MIPS32: # %bb.0: # %entry
; MIPS32-NEXT: addiu $sp, $sp, -24 ; MIPS32-NEXT: addiu $sp, $sp, -24
@ -117,7 +116,8 @@ define void @foo() #0 {
; MIPS32-MM-PIC-NEXT: jr $ra ; MIPS32-MM-PIC-NEXT: jr $ra
; MIPS32-MM-PIC-NEXT: addiu $sp, $sp, 24 ; MIPS32-MM-PIC-NEXT: addiu $sp, $sp, 24
entry: entry:
call void @_mcount()
ret void ret void
} }
attributes #0 = { "instrument-function-entry-inlined"="_mcount" } declare void @_mcount()

View File

@ -1,4 +1,4 @@
; RUN: opt -ee-instrument < %s | opt -inline | llc -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s ; RUN: opt -ee-instrument < %s | opt -inline | opt -post-inline-ee-instrument | llc -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s
; The run-line mimics how Clang might run the instrumentation passes. ; The run-line mimics how Clang might run the instrumentation passes.

View File

@ -24,7 +24,6 @@
; CHECK-NEXT: Shadow Stack GC Lowering ; CHECK-NEXT: Shadow Stack GC Lowering
; CHECK-NEXT: Lower constant intrinsics ; CHECK-NEXT: Lower constant intrinsics
; CHECK-NEXT: Remove unreachable blocks from the CFG ; CHECK-NEXT: Remove unreachable blocks from the CFG
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics ; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Expand indirectbr instructions ; CHECK-NEXT: Expand indirectbr instructions

View File

@ -13,6 +13,7 @@ target triple = "i386-pc-windows-msvc19.16.0"
declare dso_local x86_thiscallcc void @methodWithVtorDisp(i8* nocapture readonly, <{ %struct.Args }>* inalloca) declare dso_local x86_thiscallcc void @methodWithVtorDisp(i8* nocapture readonly, <{ %struct.Args }>* inalloca)
; Function Attrs: nounwind optsize
define dso_local x86_thiscallcc void @methodWithVtorDisp_thunk(i8* %0, <{ %struct.Args }>* inalloca %1) #0 { define dso_local x86_thiscallcc void @methodWithVtorDisp_thunk(i8* %0, <{ %struct.Args }>* inalloca %1) #0 {
; CHECK-LABEL: methodWithVtorDisp_thunk: ; CHECK-LABEL: methodWithVtorDisp_thunk:
; CHECK: # %bb.0: ; CHECK: # %bb.0:
@ -31,8 +32,16 @@ define dso_local x86_thiscallcc void @methodWithVtorDisp_thunk(i8* %0, <{ %struc
%5 = load i32, i32* %4, align 4 %5 = load i32, i32* %4, align 4
%6 = sub i32 0, %5 %6 = sub i32 0, %5
%7 = getelementptr i8, i8* %0, i32 %6 %7 = getelementptr i8, i8* %0, i32 %6
%8 = call i8* @llvm.returnaddress(i32 0)
call void @__cyg_profile_func_exit(i8* bitcast (void (i8*, <{ %struct.Args }>*)* @methodWithVtorDisp_thunk to i8*), i8* %8)
musttail call x86_thiscallcc void @methodWithVtorDisp(i8* %7, <{ %struct.Args }>* inalloca nonnull %1) musttail call x86_thiscallcc void @methodWithVtorDisp(i8* %7, <{ %struct.Args }>* inalloca nonnull %1)
ret void ret void
} }
attributes #0 = { nounwind optsize "instrument-function-exit-inlined"="__cyg_profile_func_exit" } declare void @__cyg_profile_func_exit(i8*, i8*)
; Function Attrs: nofree nosync nounwind readnone willreturn
declare i8* @llvm.returnaddress(i32 immarg) #1
attributes #0 = { nounwind optsize }
attributes #1 = { nofree nosync nounwind readnone willreturn }

View File

@ -53,7 +53,6 @@
; CHECK-NEXT: Constant Hoisting ; CHECK-NEXT: Constant Hoisting
; CHECK-NEXT: Replace intrinsics with calls to vector library ; CHECK-NEXT: Replace intrinsics with calls to vector library
; CHECK-NEXT: Partially inline calls to library functions ; CHECK-NEXT: Partially inline calls to library functions
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics ; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics ; CHECK-NEXT: Expand reduction intrinsics
; CHECK-NEXT: Interleaved Access Pass ; CHECK-NEXT: Interleaved Access Pass

View File

@ -6,7 +6,6 @@
; CHECK-NEXT: Target Transform Information ; CHECK-NEXT: Target Transform Information
; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Lower the matrix intrinsics (minimal) ; CHECK-NEXT: Lower the matrix intrinsics (minimal)

View File

@ -10,7 +10,6 @@
; CHECK-NEXT: FunctionPass Manager ; CHECK-NEXT: FunctionPass Manager
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-EXT: Good Bye World Pass ; CHECK-EXT: Good Bye World Pass
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Pass Arguments: ; CHECK-NEXT: Pass Arguments:
; CHECK-NEXT: Target Library Information ; CHECK-NEXT: Target Library Information
; CHECK-NEXT: Target Transform Information ; CHECK-NEXT: Target Transform Information

View File

@ -12,7 +12,6 @@
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-EXT: Good Bye World Pass ; CHECK-EXT: Good Bye World Pass
; CHECK-NOEXT-NOT: Good Bye World Pass ; CHECK-NOEXT-NOT: Good Bye World Pass
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Simplify the CFG
; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: SROA ; CHECK-NEXT: SROA

View File

@ -12,7 +12,6 @@
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-EXT: Good Bye World Pass ; CHECK-EXT: Good Bye World Pass
; CHECK-NOEXT-NOT: Good Bye World Pass ; CHECK-NOEXT-NOT: Good Bye World Pass
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Simplify the CFG
; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: SROA ; CHECK-NEXT: SROA

View File

@ -12,7 +12,6 @@
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-EXT: Good Bye World Pass ; CHECK-EXT: Good Bye World Pass
; CHECK-NOEXT-NOT: Good Bye World Pass ; CHECK-NOEXT-NOT: Good Bye World Pass
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Simplify the CFG
; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: SROA ; CHECK-NEXT: SROA

View File

@ -12,7 +12,6 @@
; CHECK-NEXT: Module Verifier ; CHECK-NEXT: Module Verifier
; CHECK-EXT: Good Bye World Pass ; CHECK-EXT: Good Bye World Pass
; CHECK-NOEXT-NOT: Good Bye World Pass ; CHECK-NOEXT-NOT: Good Bye World Pass
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (pre inlining)
; CHECK-NEXT: Simplify the CFG ; CHECK-NEXT: Simplify the CFG
; CHECK-NEXT: Dominator Tree Construction ; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: SROA ; CHECK-NEXT: SROA