Good time of the day!
I've ported ASAN to proprietary system, where I (besides everything else) need to instrument application startup code. To accomplish this task I've added check for appropriate function name and triple in maybeInsertAsanInitAtFunctionEntry(). However I got following IR after that:
define void @_startup() #0 { entry: %0 = load i64, i64* @__asan_shadow_memory_dynamic_address call void @__asan_init() .....
Needless to say that it doesn't work as expected, because asan_shadow_memory_dynamic_address is initialized in asan_init().
This patch fixes the problem for me, by enforcing correct order of operations.
I don't know how to write unit test for it, so any suggestions/comments are appreciated.
Thanks.