diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2019-01-25 02:08:46 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2019-01-25 02:08:46 +0000 |
commit | 1a8acfb7682d5a28d4fabaef5f75dc394898661f (patch) | |
tree | 8a0ff3ef818bbf24a72ce5dc4799e9981ee7cc8e /llvm/lib/Transforms | |
parent | f4e7051c6736e83facc072e06344b7b52bbf2183 (diff) | |
download | bcm5719-llvm-1a8acfb7682d5a28d4fabaef5f75dc394898661f.tar.gz bcm5719-llvm-1a8acfb7682d5a28d4fabaef5f75dc394898661f.zip |
hwasan: If we split the entry block, move static allocas back into the entry block.
Otherwise they are treated as dynamic allocas, which ends up increasing
code size significantly. This reduces size of Chromium base_unittests
by 2MB (6.7%).
Differential Revision: https://reviews.llvm.org/D57205
llvm-svn: 352152
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 6170b792a68..a6ffff418db 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -1038,6 +1038,21 @@ bool HWAddressSanitizer::runOnFunction(Function &F) { Changed |= instrumentStack(AllocasToInstrument, RetVec, StackTag); } + // If we split the entry block, move any allocas that were originally in the + // entry block back into the entry block so that they aren't treated as + // dynamic allocas. + if (EntryIRB.GetInsertBlock() != &F.getEntryBlock()) { + InsertPt = &*F.getEntryBlock().begin(); + for (auto II = EntryIRB.GetInsertBlock()->begin(), + IE = EntryIRB.GetInsertBlock()->end(); + II != IE;) { + Instruction *I = &*II++; + if (auto *AI = dyn_cast<AllocaInst>(I)) + if (isa<ConstantInt>(AI->getArraySize())) + I->moveBefore(InsertPt); + } + } + for (auto Inst : ToInstrument) Changed |= instrumentMemAccess(Inst); |