简体   繁体   English

如何在不优化的情况下生成 LLVM IR

[英]How to generate LLVM IR without optimization

I am writing an LLVM PASS to analyze info in registers.我正在编写一个 LLVM PASS 来分析寄存器中的信息。 It seems that IRBuilder optimized my code automatically, making an expression to be an operand.似乎IRBuilder自动优化了我的代码,使表达式成为操作数。 For example, I write down below code to generate LLVM IR.例如,我写下下面的代码来生成 LLVM IR。

// %reg = getelementptr inbounds ([128 x i256], [128 x i256]* @mstk, i256 0, i256 0
std::vector<llvm::Value*> indices(2, llvm::ConstantInt::get(Type::Int256Ty, 0));
llvm::ArrayRef<llvm::Value *> indicesRef(indices);
llvm::Value* m_sp = m_builder.CreateGEP(conArray, indicesRef, "spPtr"); 

// store 0, *%m_sp
m_builder.CreateStore(llvm::ConstantInt::get(Type::Int256Ty, 0), m_sp); 

The expected IR should consist of two registers.预期的 IR 应包含两个寄存器。 (see below) (见下文)

%reg = getelementptr inbounds ([128 x i256], [128 x i256]* @mstk, i256 0, i256 0)
store i256 0, i256* reg

Unfortunately, IRBuilder optimizes the IR by combining the registers.不幸的是,IRBuilder 通过组合寄存器来优化 IR。

store i256 0, i256* getelementptr inbounds ([128 x i256], [128 x i256]* @mstk, i256 0, i256 0)

Is it possible to disable the IR optimization?是否可以禁用 IR 优化? I have made sure that I turned off all PASS.我已经确保我关闭了所有 PASS。 Thanks.谢谢。

I solved this problem by disabling the constant folder of IR builder.我通过禁用 IR 生成器的常量文件夹解决了这个问题。 See Disable constant folding for LLVM 10 C++ API请参阅禁用 LLVM 10 C++ API 的常量折叠

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM