[llvm-dev] How can I make llvm intrinsic functions declarations survive from optimizations.
Zhengyang Liu via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 30 04:59:02 PDT 2016
Dear Sanjoy Das and community.
I was tried to fix a bug in the pass InitAllocas from SAFECode. This is a function pass and will insert a prototype of 'llvm.memset.p0i8.i32' in the module at doInitialize() stage of the pass. But, this prototype will be eliminated by strip unused function optimization since there is no call on this function after doInitialization(). Therefore there will be no prototype at the runOnFunction() stage, and this will cause a fail. Previously I solve this kind of bug by inserting the prototype of the function to llvm.compiler.used. In this way, the compiler will not leave the prototype alone. This time, the situation is a bit complicated, inserting the intrinsic function to llvm.compiler.used will cause a fail because only users of direct call/invokes are allowed on intrinsic functions.
Fortunately, after some discussion with my GSoC mentor, Prof. Criswell, we chose to rewrite the pass to a module pass, this solves this issue perfectly. Thanks for your patience.
From: Sanjoy Das <sanjoy at playingwithpointers.com>
Sent: Thursday, June 23, 2016 3:44:09 PM
To: Zhengyang Liu
Cc: llvm-dev at lists.llvm.org
Subject: Re: [llvm-dev] How can I make llvm intrinsic functions declarations survive from optimizations.
Do you mind sharing _why_ you need the intrinsic declarations to stay
around? It is possible that there is a better way of solving your
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev