[llvm-dev] Proper way to lower all ConstantExprs?

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Thu May 31 10:59:21 PDT 2018


On 5/30/2018 7:21 PM, mayuyu.io via llvm-dev wrote:
> Hi:
> For my own Transform passes I need to lower all ConstantExpressions into Instructions in order to conveniently analyze the use-def def-use chains and operand comparisons. Could anyone possibly kindly share some insights on if there is any standard way to do this without crafting my own implementation and if not, should we add this feature into LLVM upstream?

There's a helper ConstantExpr::getAsInstruction to create an Instruction 
for a given ConstantExpr.  I don't think there's any code to do this for 
*all* ConstantExprs/ConstantAggregates used by a given function; if you 
think you need this, you might want to reconsider your approach.  
(Recursively visiting constant expressions isn't very hard, if you need it.)

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list