deploy-20250820-3 #1
@@ -408,7 +408,7 @@ std::any SysYIRGenerator::visitFuncDef(SysYParser::FuncDefContext *ctx){
|
||||
|
||||
// 在处理函数体之前,创建一个新的基本块作为函数体的实际入口
|
||||
// 这样 entryBB 就可以在完成初始化后跳转到这里
|
||||
BasicBlock* funcBodyEntry = function->addBasicBlock("funcBodyEntry");
|
||||
BasicBlock* funcBodyEntry = function->addBasicBlock("funcBodyEntry_" + name);
|
||||
|
||||
// 从 entryBB 无条件跳转到 funcBodyEntry
|
||||
builder.createUncondBrInst(funcBodyEntry, {});
|
||||
|
||||
@@ -150,9 +150,7 @@ void SysYPrinter::printFunction(Function *function) {
|
||||
for (const auto &blockIter : function->getBasicBlocks()) {
|
||||
// Basic block label
|
||||
BasicBlock* blockPtr = blockIter.get();
|
||||
if (blockPtr == function->getEntryBlock()) {
|
||||
std::cout << "entry:" << std::endl;
|
||||
} else if (!blockPtr->getName().empty()) {
|
||||
if (!blockPtr->getName().empty()) {
|
||||
std::cout << blockPtr->getName() << ":" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -1248,7 +1248,7 @@ class Function : public Value {
|
||||
friend class Module;
|
||||
protected:
|
||||
Function(Module *parent, Type *type, const std::string &name) : Value(type, name), parent(parent) {
|
||||
blocks.emplace_back(new BasicBlock(this));
|
||||
blocks.emplace_back(new BasicBlock(this, "entry_" + name)); ///< 创建一个入口基本块
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user