]> granicus.if.org Git - clang/commit
[Coroutines] Schedule coro-split before asan
authorBrian Gesiak <modocache@gmail.com>
Sun, 1 Apr 2018 23:55:21 +0000 (23:55 +0000)
committerBrian Gesiak <modocache@gmail.com>
Sun, 1 Apr 2018 23:55:21 +0000 (23:55 +0000)
commit74164684a16a38e0c1e866078a414a9eabf15aee
tree6c66243cb124332488781a7d1777ee1512dc5844
parentd2efb713d778dd79287928fcd897b46b4bd00b10
[Coroutines] Schedule coro-split before asan

Summary:
The docs for the LLVM coroutines intrinsic `@llvm.coro.id` state that
"The second argument, if not null, designates a particular alloca instruction
to be a coroutine promise."

However, if the address sanitizer pass is run before the `@llvm.coro.id`
intrinsic is lowered, the `alloca` instruction passed to the intrinsic as its
second argument is converted, as per the
https://github.com/google/sanitizers/wiki/AddressSanitizerAlgorithm docs, to
an `inttoptr` instruction that accesses the address of the promise.

On optimization levels `-O1` and above, the `-asan` pass is run after
`-coro-early`, `-coro-split`, and `-coro-elide`, and before
`-coro-cleanup`, and so there is no issue. At `-O0`, however, `-asan`
is run in between `-coro-early` and `-coro-split`, which causes an
assertion to be hit when the `inttoptr` instruction is forcibly cast to
an `alloca`.

Rearrange the passes such that the coroutine passes are registered
before the sanitizer passes.

Test Plan:
Compile a simple C++ program that uses coroutines in `-O0` with
`-fsanitize-address`, and confirm no assertion is hit:
`clang++ coro-example.cpp -fcoroutines-ts -g -fsanitize=address -fno-omit-frame-pointer`.

Reviewers: GorNishanov, lewissbaker, EricWF

Reviewed By: GorNishanov

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D43927

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328951 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/BackendUtil.cpp