From fe4f3bb45fa3c09e25feaf797d01f83d5736ad5f Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Thu, 15 Jul 2021 19:08:46 -0700 Subject: [PATCH] Moved storepre to after the last hdse phase because storepre cannot maintain correct SSA This fixes the execution failure when pr68841.c is compiled with inlining and mplme at -O3 --- src/mapleall/maple_driver/defs/phases.def | 2 +- src/mapleall/maple_ir/src/mir_type.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mapleall/maple_driver/defs/phases.def b/src/mapleall/maple_driver/defs/phases.def index b495f817c8..749a7e0352 100644 --- a/src/mapleall/maple_driver/defs/phases.def +++ b/src/mapleall/maple_driver/defs/phases.def @@ -62,9 +62,9 @@ ADD_PHASE("rclowering", JAVALANG && !MeOption::noRC && MeOption::rcLowering && ! ADD_PHASE("gclowering", JAVALANG && MeOption::gcOnly) ADD_PHASE("rename2preg", MeOption::optLevel >= 2) ADD_PHASE("lpre", MeOption::optLevel >= 2) -ADD_PHASE("storepre", MeOption::optLevel >= 2) ADD_PHASE("copyprop", MeOption::optLevel >= 2 && !JAVALANG) ADD_PHASE("hdse", MeOption::optLevel >= 2 && !JAVALANG) +ADD_PHASE("storepre", MeOption::optLevel >= 2) ADD_PHASE("pregrename", MeOption::optLevel >= 2) ADD_PHASE("bblayout", MeOption::optLevel >= 2 || JAVALANG) ADD_PHASE("emit", MeOption::optLevel >= 2 || JAVALANG) diff --git a/src/mapleall/maple_ir/src/mir_type.cpp b/src/mapleall/maple_ir/src/mir_type.cpp index 60b09e5faf..18bb58d2a0 100644 --- a/src/mapleall/maple_ir/src/mir_type.cpp +++ b/src/mapleall/maple_ir/src/mir_type.cpp @@ -1979,8 +1979,10 @@ TyIdxFieldAttrPair MIRPtrType::GetPointedTyIdxFldAttrPairWithFieldID(FieldID fld } MIRType *ty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(pointedTyIdx); MIRStructType *structTy = ty->EmbeddedStructType(); - CHECK_FATAL(structTy, - "MIRPtrType::GetPointedTyidxWithFieldId(): cannot have non-zero fieldID for something other than a struct"); + if (structTy == nullptr) { + // this can happen due to casting in C; just return the pointed to type + return TyIdxFieldAttrPair(pointedTyIdx, FieldAttrs()); + } return structTy->TraverseToField(fldId).second; } -- Gitee