[llvm-dev] how to generate select-free LLVM IR?

144 views
Skip to first unread message

Robert Henry via llvm-dev

unread,
Aug 2, 2019, 3:03:36 PM8/2/19
to llvm...@lists.llvm.org
I run "clang ... --emit-llvm ....".  I get LLVM IR select instructions out. I don't want select instructions, but want explicit control flow.

Is there a way to do this?

I'm scared of disabling the SimplifyCFG pass since it appears to do much more than just rewrite to use select statements.

Eli Friedman via llvm-dev

unread,
Aug 2, 2019, 3:16:32 PM8/2/19
to Robert Henry, llvm-dev

Probably you want to a pass to transform select instructions to control flow late, after optimizations have run.  Trying to prevent clang IR generation and IR optimizations from forming selects is way too difficult.

 

I don’t think this transform exists as an independent pass, but you can borrow code from CodeGenPrepare::optimizeSelectInst.

 

-Eli

Maxime Arthaud via llvm-dev

unread,
Aug 4, 2019, 2:37:44 PM8/4/19
to Eli Friedman, Robert Henry, llvm-dev
Hi Robert,


You could write your own LLVM pass that lowers select instructions.


Many static analyzers based on LLVM actually do that. See for instance
in IKOS:
https://github.com/NASA-SW-VnV/ikos/blob/master/frontend/llvm/src/pass/lower_select.cpp


Best,

--
Maxime Arthaud

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Reply all
Reply to author
Forward
0 new messages