Lab6: fix performance test freeze by only zero-initializing local variables with initializers
This commit is contained in:
4
scripts/run_all_tests.sh
Normal file → Executable file
4
scripts/run_all_tests.sh
Normal file → Executable file
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# 批量测试所有.sy文件的语法解析
|
# 批量测试所有.sy文件的语法解析
|
||||||
|
|
||||||
test_dir="/home/lingli/nudt-compiler-cpp/test/test_case"
|
test_dir="$(pwd)/test/test_case"
|
||||||
compiler="/home/lingli/nudt-compiler-cpp/build/bin/compiler"
|
compiler="$(pwd)/build/bin/compiler"
|
||||||
|
|
||||||
if [ ! -f "$compiler" ]; then
|
if [ ! -f "$compiler" ]; then
|
||||||
echo "错误:编译器不存在,请先构建项目"
|
echo "错误:编译器不存在,请先构建项目"
|
||||||
|
|||||||
@@ -208,8 +208,10 @@ std::any IRGenImpl::visitVarDef(SysYParser::VarDefContext* ctx) {
|
|||||||
slot = module_.CreateGlobalValue(name, StorageType(ty), init);
|
slot = module_.CreateGlobalValue(name, StorageType(ty), init);
|
||||||
} else {
|
} else {
|
||||||
slot = builder_.CreateAlloca(StorageType(ty), name);
|
slot = builder_.CreateAlloca(StorageType(ty), name);
|
||||||
ZeroInitializeLocal(slot, ty);
|
if (ctx->initValue()) {
|
||||||
if (ctx->initValue()) EmitLocalInitValue(slot, ty, ctx->initValue());
|
ZeroInitializeLocal(slot, ty);
|
||||||
|
EmitLocalInitValue(slot, ty, ctx->initValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
storage_map_[ctx] = slot;
|
storage_map_[ctx] = slot;
|
||||||
|
|||||||
Reference in New Issue
Block a user