llvm.org GIT mirror llvm / 2b97eb2
[asan] Fix instruction emission ordering with dynamic shadow. Summary: Instrumentation to copy byval arguments is now correctly inserted after the dynamic shadow base is loaded. Reviewers: vitalybuka, eugenis Reviewed By: vitalybuka Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D36533 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310503 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Morehouse 2 years ago
2 changed file(s) with 9 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
755755 bool runOnFunction() {
756756 if (!ClStack) return false;
757757
758 if (ClRedzoneByvalArgs && Mapping.Offset != kDynamicShadowSentinel)
758 if (ClRedzoneByvalArgs)
759759 copyArgsPassedByValToAllocas();
760760
761761 // Collect alloca, ret, lifetime instructions etc.
25452545 }
25462546
25472547 void FunctionStackPoisoner::copyArgsPassedByValToAllocas() {
2548 BasicBlock &FirstBB = *F.begin();
2549 IRBuilder<> IRB(&FirstBB, FirstBB.getFirstInsertionPt());
2548 Instruction *CopyInsertPoint = &F.front().front();
2549 if (CopyInsertPoint == ASan.LocalDynamicShadow) {
2550 // Insert after the dynamic shadow location is determined
2551 CopyInsertPoint = CopyInsertPoint->getNextNode();
2552 assert(CopyInsertPoint);
2553 }
2554 IRBuilder<> IRB(CopyInsertPoint);
25502555 const DataLayout &DL = F.getParent()->getDataLayout();
25512556 for (Argument &Arg : F.args()) {
25522557 if (Arg.hasByValAttr()) {
0 ; This check verifies that arguments passed by value get redzones.
11 ; RUN: opt < %s -asan -asan-realign-stack=32 -S | FileCheck %s
2 ; RUN: opt < %s -asan -asan-realign-stack=32 -asan-force-dynamic-shadow -S | FileCheck %s --check-prefixes=CHECK-FDS
2 ; RUN: opt < %s -asan -asan-realign-stack=32 -asan-force-dynamic-shadow -S | FileCheck %s
33
44
55 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
88 %struct.A = type { [8 x i32] }
99
1010 declare i32 @bar(%struct.A*)
11
12 ; CHECK-FDS-NOT: {{\.byval}}
1311
1412 ; Test behavior for named argument with explicit alignment. The memcpy and
1513 ; alloca alignments should match the explicit alignment of 64.