[llvm-commits] [llvm] r166267 - in /llvm/trunk: lib/Transforms/Instrumentation/AddressSanitizer.cpp test/Instrumentation/AddressSanitizer/basic.ll

Chandler Carruth chandlerc at google.com
Thu Oct 18 23:32:11 PDT 2012


On Thu, Oct 18, 2012 at 11:20 PM, Kostya Serebryany <kcc at google.com> wrote:

> Author: kcc
> Date: Fri Oct 19 01:20:53 2012
> New Revision: 166267
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166267&view=rev
> Log:
> [asan] make sure asan erases old unused allocas after it created a new
> one. This became important after the recent move from ModulePass to
> FunctionPass because no cleanup is happening after asan pass any more.
>

We should almost certainly run a few passes after asan. instcombine, gvn,
instcombine, and simplifycfg would be my baseline to experiment with (and
compare compile times of). GVN is likely the most expensive, and it might
be acceptable to just do instcombine + simplifycfg.

Don't get me wrong, this change is still a good idea -- you can eliminate
these allocas more cheaply than anything else.


>
> Modified:
>     llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
>     llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=166267&r1=166266&r2=166267&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Fri Oct
> 19 01:20:53 2012
> @@ -1148,6 +1148,10 @@
>      }
>    }
>
> +  // We are done. Remove the old unused alloca instructions.
> +  for (size_t i = 0, n = AllocaVec.size(); i < n; i++)
> +    AllocaVec[i]->eraseFromParent();
> +
>    if (ClDebugStack) {
>      DEBUG(dbgs() << F);
>    }
>
> Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll?rev=166267&r1=166266&r2=166267&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll (original)
> +++ llvm/trunk/test/Instrumentation/AddressSanitizer/basic.ll Fri Oct 19
> 01:20:53 2012
> @@ -69,3 +69,23 @@
>    store i32 42, i32* %a
>    ret void
>  }
> +
> +; Check that asan leaves just one alloca.
> +
> +declare void @alloca_test_use([10 x i8]*)
> +define void @alloca_test() address_safety {
> +entry:
> +  %x = alloca [10 x i8], align 1
> +  %y = alloca [10 x i8], align 1
> +  %z = alloca [10 x i8], align 1
> +  call void @alloca_test_use([10 x i8]* %x)
> +  call void @alloca_test_use([10 x i8]* %y)
> +  call void @alloca_test_use([10 x i8]* %z)
> +  ret void
> +}
> +
> +; CHECK: define void @alloca_test()
> +; CHECK: = alloca
> +; CHECK-NOT: = alloca
> +; CHECK: ret void
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121018/fa053868/attachment.html>


More information about the llvm-commits mailing list