Zhengyang Liu via llvm-dev
2016-Jun-23 06:46 UTC
[llvm-dev] How can I make llvm intrinsic functions declarations survive from optimizations.
Dear LLVM community. I have a function pass. This pass will insert a llvm intrinsic function prototype (llvm.memset.p0i8.i32) to the module at the doInitialize stage. Then at runOnFunction Stage, this pass will find the insert points and insert calls of this intrinsic function. However, when the -O2 flag is turned on, the strip unused function optimization will automatically delete this intrinsic function because there's no use of this function found. (Strip unused function happens before runOnFunction of my pass). I used to solve this kind of problems on non-intrinsic functions by inserting a record to llvm.compiler.used. However, after I append this intrinsic function to llvm.compiler.used global, I got a fatal error Invalid user of intrinsic instruction! i8* bitcast (void (i8*, i8, i32, i32, i1)* @llvm.memset.p0i8.i32 to i8*) fatal error: error in backend: Broken module found, compilation aborted! I noticed that, only user of direct call/invokes are allowed for intrinsic functions. So is it impossible to solve this problem by inserting intrinsic function prototype? Could you please give me some ideas on this , to make these intrinsic functions prototypes survive from llvm optimizations? Thank you. Best regards, Zhengyang.
Sanjoy Das via llvm-dev
2016-Jun-23 07:44 UTC
[llvm-dev] How can I make llvm intrinsic functions declarations survive from optimizations.
Hi Zhengyang, 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 problem. Thanks! -- Sanjoy
Zhengyang Liu via llvm-dev
2016-Jun-30 11:59 UTC
[llvm-dev] How can I make llvm intrinsic functions declarations survive from optimizations.
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. Best regards, Zhengyang. ________________________________ 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. Hi Zhengyang, 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 problem. Thanks! -- Sanjoy -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160630/9a8604a6/attachment.html>
Seemingly Similar Threads
- How can I make llvm intrinsic functions declarations survive from optimizations.
- How can I make llvm intrinsic functions declarations survive from optimizations.
- [GSoC'16] Weekly Status - June 27 - Zhengyang Liu
- [GSoC'16] Add a Scheme Frontend for LLVM
- [GSoC'16] Proposal for Enhance SAFECode’s Baggy Bounds Checking