diff --git a/build/core/maple_test.mk b/build/core/maple_test.mk
index 9a0602b436ca45b0985ebe21265ae9667341247b..a1f421df8c07d3e7b3ab8d7102292f07f48ca228 100644
--- a/build/core/maple_test.mk
+++ b/build/core/maple_test.mk
@@ -15,3 +15,4 @@ clean:
@rm -f *.groots.txt
@rm -f *.primordials.txt
@rm -rf comb.log
+ @rm -rf *.muid
diff --git a/doc/Programming_Specifications.md b/doc/Programming_Specifications.md
index dc13e022b137ba1fd1c32fbd0d27395c0fa4f852..826f0d99464e8a6f6e07e80e93ab1720a692d320 100644
--- a/doc/Programming_Specifications.md
+++ b/doc/Programming_Specifications.md
@@ -557,7 +557,7 @@ default: // Bad: default 未缩进
// 假设下面第一行已经不满足行宽要求
```cpp
if (currentValue > threshold &&
- someConditionsion) {
+ someConditionsion) {
DoSomething();
...
}
@@ -612,10 +612,14 @@ const int rank[] = {
```
## 指针与引用
-### 建议3.12.1 指针类型"`*`"跟随变量名,并与类型之间有一个空格
-
+### 建议3.12.1 指针类型"`*`"跟随变量名或者类型,不要两边都留有或者都没有空格
+指针命名: `*`靠左靠右都可以,但是不要两边都有或者都没有空格。
```cpp
+int* p = nullptr; // Good
int *p = nullptr; // Good
+
+int*p = nullptr; // Bad
+int * p = nullptr; // Bad
```
例外:当变量被 const 修饰时,"`*`" 无法跟随变量,此时也不要跟随类型。
@@ -623,12 +627,16 @@ int *p = nullptr; // Good
char * const VERSION = "V100";
```
-### 建议3.12.2 引用类型"`&`"跟随变量名,并与类型之间有一个空格
-
+### 建议3.12.2 引用类型"`&`"跟随变量名或者类型,不要两边都留有或者都没有空格
+引用命名:`&`靠左靠右都可以,但是不要两边都有或者都没有空格。
```cpp
int i = 8;
+int& p = i; // Good
int &p = i; // Good
+
+int & p = i; // Bad
+int&p = i; // Bad
```
## 编译预处理
diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl
index 51eaf158335be60db30f8dc54f1d816e7073d01a..285173f5496087782ae9ddb3513f39639124660b 100755
Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ
diff --git a/src/bin/maple b/src/bin/maple
index 3c894dc2065639965f7246dbd6880f6dba0d8731..cb9e09590c4f92b75665d57efb2a934e236a38cc 100755
Binary files a/src/bin/maple and b/src/bin/maple differ
diff --git a/src/bin/mplcg b/src/bin/mplcg
index 152930e4d0a333c61f7b0185f16d2f5ae9a5058b..f29743b12145e1e23d3b50349488fd7d81c67cfb 100755
Binary files a/src/bin/mplcg and b/src/bin/mplcg differ
diff --git a/src/maple_driver/include/compiler.h b/src/maple_driver/include/compiler.h
index db1b6af82f0dc7c58a561b6dc8857be3e6a2e33f..ec60988123110edaa148e3fe8e6a74d8513bc651 100644
--- a/src/maple_driver/include/compiler.h
+++ b/src/maple_driver/include/compiler.h
@@ -129,7 +129,7 @@ class MapleCombCompiler : public Compiler {
const std::unordered_set GetFinalOutputs(const MplOptions &mplOptions) const;
private:
- MeOptions *MakeMeOptions(const MplOptions &options, MemPool *optmp);
+ MeOption *MakeMeOptions(const MplOptions &options, MemPool *optmp);
Options *MakeMpl2MplOptions(const MplOptions &options, MemPool *optmp);
std::string realRunningExe;
};
diff --git a/src/maple_driver/include/driver_runner.h b/src/maple_driver/include/driver_runner.h
index ccc9a9b9a92b13c434854eeac05dae79b731acc0..267bdd9ea31a0df67bd8af2eeef9055ad984beea 100644
--- a/src/maple_driver/include/driver_runner.h
+++ b/src/maple_driver/include/driver_runner.h
@@ -31,7 +31,7 @@ namespace maple {
class DriverRunner final {
public:
DriverRunner(MIRModule *theModule, const std::vector &exeNames, Options *mpl2mplOptions,
- std::string mpl2mplInput, MeOptions *meOptions, std::string meInput, std::string actualInput,
+ std::string mpl2mplInput, MeOption *meOptions, std::string meInput, std::string actualInput,
MemPool *optMp, bool timePhases = false,
bool genMemPl = false)
: theModule(theModule),
@@ -63,7 +63,7 @@ class DriverRunner final {
this->mpl2mplInput = mpl2mplInput;
}
- void SetMeInfo(MeOptions *meOptions, const std::string &meInput) {
+ void SetMeInfo(MeOption *meOptions, const std::string &meInput) {
this->meOptions = meOptions;
this->meInput = meInput;
}
@@ -74,7 +74,7 @@ class DriverRunner final {
std::vector exeNames;
Options *mpl2mplOptions = nullptr;
std::string mpl2mplInput;
- MeOptions *meOptions = nullptr;
+ MeOption *meOptions = nullptr;
std::string meInput;
std::string actualInput;
MemPool *optMp;
diff --git a/src/maple_driver/src/maple_comb_compiler.cpp b/src/maple_driver/src/maple_comb_compiler.cpp
index 8578aa3340038e6c83f04e1040a86fd1abe286fa..27cb49ba530dedae08bff49b482585b90deb787f 100644
--- a/src/maple_driver/src/maple_comb_compiler.cpp
+++ b/src/maple_driver/src/maple_comb_compiler.cpp
@@ -70,8 +70,8 @@ void MapleCombCompiler::PrintCommand(const MplOptions &options) const {
<< GetInputFileName(options) << options.printCommandStr << std::endl;
}
-MeOptions *MapleCombCompiler::MakeMeOptions(const MplOptions &options, maple::MemPool *optMp) {
- MeOptions *meOption = new MeOptions(optMp);
+MeOption *MapleCombCompiler::MakeMeOptions(const MplOptions &options, maple::MemPool *optMp) {
+ MeOption *meOption = new MeOption(*optMp);
auto inputMeOptions = options.exeOptions.find(kBinNameMe);
if (inputMeOptions == options.exeOptions.end()) {
LogInfo::MapleLogger() << "no me input options" << std::endl;
@@ -84,11 +84,11 @@ MeOptions *MapleCombCompiler::MakeMeOptions(const MplOptions &options, maple::Me
}
switch (opt.Index()) {
case kMeSkipPhases:
- meOption->SplitPhases(opt.Args().c_str(), meOption->GetSkipPhases());
+ meOption->SplitPhases(opt.Args(), meOption->GetSkipPhases());
break;
case kMeRange:
meOption->useRange = true;
- meOption->GetRange(opt.Args().c_str());
+ meOption->GetRange(opt.Args());
break;
case kMeDumpAfter:
meOption->dumpAfter = true;
@@ -97,7 +97,7 @@ MeOptions *MapleCombCompiler::MakeMeOptions(const MplOptions &options, maple::Me
meOption->dumpFunc = opt.Args();
break;
case kMeDumpPhases:
- meOption->SplitPhases(opt.Args().c_str(), meOption->dumpPhases);
+ meOption->SplitPhases(opt.Args(), meOption->dumpPhases);
break;
case kMeQuiet:
meOption->quiet = true;
@@ -165,7 +165,7 @@ MeOptions *MapleCombCompiler::MakeMeOptions(const MplOptions &options, maple::Me
}
Options *MapleCombCompiler::MakeMpl2MplOptions(const MplOptions &options, maple::MemPool *optMp) {
- Options *mpl2mplOption = new Options(optMp);
+ Options *mpl2mplOption = new Options(*optMp);
auto inputOptions = options.exeOptions.find(kBinNameMpl2mpl);
if (inputOptions == options.exeOptions.end()) {
LogInfo::MapleLogger() << "no mpl2mpl input options" << std::endl;
@@ -241,7 +241,7 @@ ErrorCode MapleCombCompiler::Compile(const MplOptions &options, MIRModulePtr &th
std::string fileName = GetInputFileName(options);
theModule = new MIRModule(fileName.c_str());
int nErr = 0;
- MeOptions *meOptions = nullptr;
+ MeOption *meOptions = nullptr;
Options *mpl2mplOptions = nullptr;
auto iterMe = std::find(options.runningExes.begin(), options.runningExes.end(), kBinNameMe);
if (iterMe != options.runningExes.end()) {
diff --git a/src/maple_ipa/src/interleaved_manager.cpp b/src/maple_ipa/src/interleaved_manager.cpp
index 414da76ea7221eec8339ed91c6e9d2fd49fde806..5b6a6f33866dc09c63743d2d96dfe289fcc1910b 100644
--- a/src/maple_ipa/src/interleaved_manager.cpp
+++ b/src/maple_ipa/src/interleaved_manager.cpp
@@ -82,7 +82,7 @@ void InterleavedManager::Run() {
compList = &mirModule.GetFunctionList();
}
for (MIRFunction *func : *compList) {
- if (MeOptions::useRange && (rangeNum < MeOptions::range[0] || rangeNum > MeOptions::range[1])) {
+ if (MeOption::useRange && (rangeNum < MeOption::range[0] || rangeNum > MeOption::range[1])) {
rangeNum++;
continue;
}
diff --git a/src/maple_ir/include/metadata_layout.h b/src/maple_ir/include/metadata_layout.h
index b8bf81641fc0be35d717e8d58eed99a5a2f39ac7..aa96da30d7ec986752f027fe926882f163fc7dd3 100644
--- a/src/maple_ir/include/metadata_layout.h
+++ b/src/maple_ir/include/metadata_layout.h
@@ -88,31 +88,8 @@ inline void *MRTGetAddressFromMetaRefOffset(MetaRefOffset *pOffset) {
return reinterpret_cast(reinterpret_cast(pOffset) + (*pOffset));
}
-struct FieldInfo {
- AddrOffset offset;
- uint32_t mod;
- uint16_t flag;
- uint16_t index;
- AddrOffset typeName;
- int32_t fieldName;
- int32_t annotation;
- int64_t declaringClass;
-};
-
-struct MethodInfo {
- AddrOffset methodInVtabIndex;
- AddrOffset addr;
- AddrOffset declaringClass;
- uint32_t mod;
- int32_t methodName;
- int32_t signatureName;
- int32_t annotationValue;
- uint16_t flag;
- uint16_t argSize;
-#ifndef USE_32BIT_REF
- uint32_t paddind;
-#endif
-};
+// MethodMeta defined in MethodMeta.h
+// FieldMeta defined in FieldMeta.h
// MethodDesc contains MethodMetadata and stack map
struct MethodDesc {
diff --git a/src/maple_ir/include/mir_builder.h b/src/maple_ir/include/mir_builder.h
index 001da552876368554420bd650bb26bc0aac0e03e..69d12e4d0fe8b3218d55a4cbc00ad9c1dfefaedd 100644
--- a/src/maple_ir/include/mir_builder.h
+++ b/src/maple_ir/include/mir_builder.h
@@ -107,10 +107,10 @@ class MIRBuilder {
MIRFunction *GetFunctionFromStidx(StIdx stIdx);
MIRFunction *GetFunctionFromName(const std::string&);
// For compiler-generated metadata struct
- void AddIntFieldConst(const MIRStructType *sType, MIRAggConst *newConst, uint32 fieldID, int64 constValue);
- void AddAddrofFieldConst(const MIRStructType *sType, MIRAggConst *newConst, uint32 fieldID, const MIRSymbol *fieldSt);
- void AddAddroffuncFieldConst(const MIRStructType *sType, MIRAggConst *newConst, uint32 fieldID,
- const MIRSymbol *funcSt);
+ void AddIntFieldConst(const MIRStructType &sType, MIRAggConst &newConst, uint32 fieldID, int64 constValue);
+ void AddAddrofFieldConst(const MIRStructType &sType, MIRAggConst &newConst, uint32 fieldID, const MIRSymbol &fieldSt);
+ void AddAddroffuncFieldConst(const MIRStructType &sType, MIRAggConst &newConst, uint32 fieldID,
+ const MIRSymbol &funcSt);
bool TraverseToNamedField(MIRStructType *structType, GStrIdx nameIdx, uint32 &fieldID);
bool IsOfSameType(MIRType *type1, MIRType *type2);
bool TraverseToNamedFieldWithTypeAndMatchStyle(MIRStructType *structType, GStrIdx nameIdx, TyIdx typeIdx,
diff --git a/src/maple_ir/include/mir_function.h b/src/maple_ir/include/mir_function.h
index 4168b4fca9817c841414bbb09244d01c145d2647..fdc261ddae8c27f149bbdee2b26dbdac088e7ccf 100644
--- a/src/maple_ir/include/mir_function.h
+++ b/src/maple_ir/include/mir_function.h
@@ -945,7 +945,6 @@ class MIRFunction {
MapleVector infoIsString; // tells if an entry has string value
MapleMap aliasVarMap; // source code alias variables for debuginfo
bool withLocInfo;
- enum { kEasumInvalid = -1, kEasumNosum = 0 };
uint8_t layoutType;
uint16 frameSize;
diff --git a/src/maple_ir/include/mir_module.h b/src/maple_ir/include/mir_module.h
index 4940b3cdb3cd0b38c3c03ee09b87d090551db1a5..7707a3e925f1778f6d3f53132bb7437ccb9d745c 100644
--- a/src/maple_ir/include/mir_module.h
+++ b/src/maple_ir/include/mir_module.h
@@ -198,6 +198,7 @@ class MIRModule {
MIRFunction *CurFunction(void) const;
MemPool *CurFuncCodeMemPool(void) const;
MapleAllocator *CurFuncCodeMemPoolAllocator(void) const;
+ MapleAllocator &GetCurFuncCodeMPAllocator(void) const;
void AddExternStructType(TyIdx tyIdx);
void AddExternStructType(const MIRType *t);
void AddSymbol(StIdx stIdx);
@@ -275,10 +276,6 @@ class MIRModule {
return optimizedFuncs.push_back(func);
}
- MapleSet &GetRcNoNeedingLock() {
- return rcNotNeedingLock;
- }
-
MapleMap*> &GetPuIdxFieldInitializedMap() {
return puIdxFieldInitializedMap;
}
@@ -507,7 +504,6 @@ class MIRModule {
MapleVector optimizedFuncs;
// Add the field for decouple optimization
std::unordered_set superCallSet;
- MapleSet rcNotNeedingLock; // set of stmtID's which does incref/decref to an object not escaping
// record all the fields that are initialized in the constructor. module scope,
// if puIdx doesn't appear in this map, it writes to all field id
// if puIdx appears in the map, but it's corresponding MapleSet is nullptr, it writes nothing fieldID
diff --git a/src/maple_ir/include/mir_nodes.h b/src/maple_ir/include/mir_nodes.h
index 370391ef25623818419f95c37c40b8c62236c35e..aad5a7b032b1474e231331bfc33968a893e702ed 100644
--- a/src/maple_ir/include/mir_nodes.h
+++ b/src/maple_ir/include/mir_nodes.h
@@ -88,8 +88,8 @@ class BaseNode {
virtual ~BaseNode() = default;
- virtual BaseNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ virtual BaseNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
virtual void DumpBase(const MIRModule *mod, int32 indent) const;
@@ -103,10 +103,6 @@ class BaseNode {
LogInfo::MapleLogger() << std::endl;
}
- virtual bool HasSymbol(MIRModule *mod, MIRSymbol *st) {
- return false;
- }
-
virtual uint8 SizeOfInstr() {
return kOpcodeInfo.GetTableItemAt(GetOpCode()).instrucSize;
}
@@ -200,8 +196,8 @@ class UnaryNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- UnaryNode *CloneTree(MapleAllocator *allocator) const {
- UnaryNode *nd = allocator->GetMemPool()->New(*this);
+ UnaryNode *CloneTree(MapleAllocator &allocator) const {
+ UnaryNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(uOpnd->CloneTree(allocator), 0);
return nd;
}
@@ -211,10 +207,6 @@ class UnaryNode : public BaseNode {
return uOpnd;
}
- bool HasSymbol(MIRModule *mod, MIRSymbol *st) {
- return uOpnd->HasSymbol(mod, st);
- }
-
uint8 NumOpnds(void) const {
return 1;
}
@@ -249,8 +241,8 @@ class TypeCvtNode : public UnaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- TypeCvtNode *CloneTree(MapleAllocator *allocator) const {
- TypeCvtNode *nd = allocator->GetMemPool()->New(*this);
+ TypeCvtNode *CloneTree(MapleAllocator &allocator) const {
+ TypeCvtNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd(0)->CloneTree(allocator), 0);
return nd;
}
@@ -280,8 +272,8 @@ class RetypeNode : public TypeCvtNode {
~RetypeNode() = default;
void Dump(const MIRModule *mod, int32 indent) const;
- RetypeNode *CloneTree(MapleAllocator *allocator) const {
- RetypeNode *nd = allocator->GetMemPool()->New(*this);
+ RetypeNode *CloneTree(MapleAllocator &allocator) const {
+ RetypeNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
}
@@ -316,8 +308,8 @@ class ExtractbitsNode : public UnaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- ExtractbitsNode *CloneTree(MapleAllocator *allocator) const {
- ExtractbitsNode *nd = allocator->GetMemPool()->New(*this);
+ ExtractbitsNode *CloneTree(MapleAllocator &allocator) const {
+ ExtractbitsNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
}
@@ -353,8 +345,8 @@ class GCMallocNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
- GCMallocNode *CloneTree(MapleAllocator *allocator) const {
- GCMallocNode *nd = allocator->GetMemPool()->New(*this);
+ GCMallocNode *CloneTree(MapleAllocator &allocator) const {
+ GCMallocNode *nd = allocator.GetMemPool()->New(*this);
return nd;
}
@@ -389,8 +381,8 @@ class JarrayMallocNode : public UnaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
- JarrayMallocNode *CloneTree(MapleAllocator *allocator) const {
- JarrayMallocNode *nd = allocator->GetMemPool()->New(*this);
+ JarrayMallocNode *CloneTree(MapleAllocator &allocator) const {
+ JarrayMallocNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
}
@@ -423,8 +415,8 @@ class IreadNode : public UnaryNode {
virtual void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IreadNode *CloneTree(MapleAllocator *allocator) const {
- IreadNode *nd = allocator->GetMemPool()->New(*this);
+ IreadNode *CloneTree(MapleAllocator &allocator) const {
+ IreadNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
}
@@ -446,12 +438,12 @@ class IreadNode : public UnaryNode {
}
// the base of an address expr is either a leaf or an iread
- BaseNode *GetAddrExprBase() const {
+ BaseNode &GetAddrExprBase() const {
BaseNode *base = Opnd();
while (base->NumOpnds() != 0 && base->GetOpCode() != OP_iread) {
base = base->Opnd(0);
}
- return base;
+ return *base;
}
protected:
@@ -475,8 +467,8 @@ class IreadoffNode : public UnaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IreadoffNode *CloneTree(MapleAllocator *allocator) const {
- IreadoffNode *nd = allocator->GetMemPool()->New(*this);
+ IreadoffNode *CloneTree(MapleAllocator &allocator) const {
+ IreadoffNode *nd = allocator.GetMemPool()->New(*this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
}
@@ -504,8 +496,8 @@ class IreadFPoffNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IreadFPoffNode *CloneTree(MapleAllocator *allocator) const {
- IreadFPoffNode *nd = allocator->GetMemPool()->New(*this);
+ IreadFPoffNode *CloneTree(MapleAllocator &allocator) const {
+ IreadFPoffNode *nd = allocator.GetMemPool()->New(*this);
return nd;
}
@@ -558,8 +550,8 @@ class BinaryNode : public BaseNode, public BinaryOpnds {
void Dump(const MIRModule *mod) const;
bool Verify() const;
- BinaryNode *CloneTree(MapleAllocator *allocator) const {
- BinaryNode *nd = allocator->GetMemPool()->New(*this);
+ BinaryNode *CloneTree(MapleAllocator &allocator) const {
+ BinaryNode *nd = allocator.GetMemPool()->New(*this);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
return nd;
@@ -580,10 +572,6 @@ class BinaryNode : public BaseNode, public BinaryOpnds {
}
}
- bool HasSymbol(MIRModule *mod, MIRSymbol *st) {
- return GetBOpnd(0)->HasSymbol(mod, st) || GetBOpnd(1)->HasSymbol(mod, st);
- }
-
BaseNode *Opnd(size_t i) const {
ASSERT(i < 2, "invalid operand idx in BinaryNode");
ASSERT(i >= 0, "invalid operand idx in BinaryNode");
@@ -622,8 +610,8 @@ class CompareNode : public BinaryNode {
void Dump(const MIRModule *mod) const;
bool Verify() const;
- CompareNode *CloneTree(MapleAllocator *allocator) const {
- CompareNode *nd = allocator->GetMemPool()->New(*this);
+ CompareNode *CloneTree(MapleAllocator &allocator) const {
+ CompareNode *nd = allocator.GetMemPool()->New(*this);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
return nd;
@@ -655,8 +643,8 @@ class DepositbitsNode : public BinaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- DepositbitsNode *CloneTree(MapleAllocator *allocator) const {
- DepositbitsNode *nd = allocator->GetMemPool()->New(*this);
+ DepositbitsNode *CloneTree(MapleAllocator &allocator) const {
+ DepositbitsNode *nd = allocator.GetMemPool()->New(*this);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
return nd;
@@ -701,8 +689,8 @@ class ResolveFuncNode : public BinaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
- ResolveFuncNode *CloneTree(MapleAllocator *allocator) const {
- ResolveFuncNode *nd = allocator->GetMemPool()->New(*this);
+ ResolveFuncNode *CloneTree(MapleAllocator &allocator) const {
+ ResolveFuncNode *nd = allocator.GetMemPool()->New(*this);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
return nd;
@@ -753,8 +741,8 @@ class TernaryNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- TernaryNode *CloneTree(MapleAllocator *allocator) const {
- TernaryNode *nd = allocator->GetMemPool()->New(*this);
+ TernaryNode *CloneTree(MapleAllocator &allocator) const {
+ TernaryNode *nd = allocator.GetMemPool()->New(*this);
nd->topnd[0] = topnd[0]->CloneTree(allocator);
nd->topnd[1] = topnd[1]->CloneTree(allocator);
nd->topnd[2] = topnd[2]->CloneTree(allocator);
@@ -779,10 +767,6 @@ class TernaryNode : public BaseNode {
return false;
}
- bool HasSymbol(MIRModule *mod, MIRSymbol *st) {
- return topnd[0]->HasSymbol(mod, st) || topnd[1]->HasSymbol(mod, st) || topnd[2]->HasSymbol(mod, st);
- }
-
private:
BaseNode *topnd[3];
};
@@ -847,8 +831,8 @@ class NaryNode : public BaseNode, public NaryOpnds {
virtual void Dump(const MIRModule *mod, int32 indent) const;
- NaryNode *CloneTree(MapleAllocator *allocator) const {
- NaryNode *nd = allocator->GetMemPool()->New(allocator, this);
+ NaryNode *CloneTree(MapleAllocator &allocator) const {
+ NaryNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -876,14 +860,6 @@ class NaryNode : public BaseNode, public NaryOpnds {
bool Verify() const {
return true;
}
-
- bool HasSymbol(MIRModule *mod, MIRSymbol *st) {
- for (size_t i = 0; i < GetNopndSize(); i++)
- if (GetNopndAt(i)->HasSymbol(mod, st)) {
- return true;
- }
- return false;
- }
};
class IntrinsicopNode : public NaryNode {
@@ -913,8 +889,8 @@ class IntrinsicopNode : public NaryNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IntrinsicopNode *CloneTree(MapleAllocator *allocator) const {
- IntrinsicopNode *nd = allocator->GetMemPool()->New(allocator, this);
+ IntrinsicopNode *CloneTree(MapleAllocator &allocator) const {
+ IntrinsicopNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -956,8 +932,8 @@ class ConstvalNode : public BaseNode {
~ConstvalNode() = default;
void Dump(const MIRModule *mod, int32 indent) const;
- ConstvalNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ ConstvalNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
const MIRConst *GetConstVal() const {
@@ -988,8 +964,8 @@ class ConststrNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
- ConststrNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ ConststrNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
UStrIdx GetStrIdx() const {
@@ -1016,8 +992,8 @@ class Conststr16Node : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
- Conststr16Node *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ Conststr16Node *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
U16StrIdx GetStrIdx() const {
@@ -1045,8 +1021,8 @@ class SizeoftypeNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- SizeoftypeNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ SizeoftypeNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
TyIdx GetTyIdx() const {
@@ -1074,8 +1050,8 @@ class FieldsDistNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
- FieldsDistNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ FieldsDistNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
TyIdx GetTyIdx() const {
@@ -1146,8 +1122,8 @@ class ArrayNode : public NaryNode {
return GetNopndSize();
}
- ArrayNode *CloneTree(MapleAllocator *allocator) const {
- ArrayNode *nd = allocator->GetMemPool()->New(allocator, this);
+ ArrayNode *CloneTree(MapleAllocator &allocator) const {
+ ArrayNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -1201,10 +1177,9 @@ class AddrofNode : public BaseNode {
virtual void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
bool CheckNode(const MIRModule *mod) const;
- bool HasSymbol(MIRModule *mod, MIRSymbol *st);
- AddrofNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ AddrofNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
const StIdx &GetStIdx() const {
@@ -1250,8 +1225,8 @@ class RegreadNode : public BaseNode {
virtual void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- RegreadNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ RegreadNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
const PregIdx &GetRegIdx() const {
@@ -1281,8 +1256,8 @@ class AddroffuncNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- AddroffuncNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ AddroffuncNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
PUIdx GetPUIdx() const {
@@ -1308,8 +1283,8 @@ class AddroflabelNode : public BaseNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- AddroflabelNode *CloneTree(MapleAllocator *allocator) const {
- return allocator->GetMemPool()->New(*this);
+ AddroflabelNode *CloneTree(MapleAllocator &allocator) const {
+ return allocator.GetMemPool()->New(*this);
}
uint32 GetOffset() const {
@@ -1426,8 +1401,8 @@ class StmtNode : public BaseNode, public PtrListNodeBase {
void InsertAfterThis(StmtNode *pos);
void InsertBeforeThis(StmtNode *pos);
- virtual StmtNode *CloneTree(MapleAllocator *allocator) const {
- StmtNode *s = allocator->GetMemPool()->New(*this);
+ virtual StmtNode *CloneTree(MapleAllocator &allocator) const {
+ StmtNode *s = allocator.GetMemPool()->New(*this);
s->SetStmtID(stmtIDNext++);
return s;
}
@@ -1514,8 +1489,8 @@ class IassignNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IassignNode *CloneTree(MapleAllocator *allocator) const {
- IassignNode *bn = allocator->GetMemPool()->New(*this);
+ IassignNode *CloneTree(MapleAllocator &allocator) const {
+ IassignNode *bn = allocator.GetMemPool()->New(*this);
bn->SetStmtID(stmtIDNext++);
bn->SetOpnd(addrExpr->CloneTree(allocator), 0);
bn->SetRHS(rhs->CloneTree(allocator));
@@ -1523,12 +1498,12 @@ class IassignNode : public StmtNode {
}
// the base of an address expr is either a leaf or an iread
- BaseNode *GetAddrExprBase() const {
+ BaseNode &GetAddrExprBase() const {
BaseNode *base = addrExpr;
while (base->NumOpnds() != 0 && base->GetOpCode() != OP_iread) {
base = base->Opnd(0);
}
- return base;
+ return *base;
}
void SetAddrExpr(BaseNode *exp) {
@@ -1561,8 +1536,8 @@ class GotoNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- GotoNode *CloneTree(MapleAllocator *allocator) const {
- GotoNode *g = allocator->GetMemPool()->New(*this);
+ GotoNode *CloneTree(MapleAllocator &allocator) const {
+ GotoNode *g = allocator.GetMemPool()->New(*this);
g->SetStmtID(stmtIDNext++);
return g;
}
@@ -1591,8 +1566,8 @@ class JsTryNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- JsTryNode *CloneTree(MapleAllocator *allocator) const {
- JsTryNode *t = allocator->GetMemPool()->New(*this);
+ JsTryNode *CloneTree(MapleAllocator &allocator) const {
+ JsTryNode *t = allocator.GetMemPool()->New(*this);
t->SetStmtID(stmtIDNext++);
return t;
}
@@ -1673,8 +1648,8 @@ class TryNode : public StmtNode {
offsets.insert(a, b, c);
}
- TryNode *CloneTree(MapleAllocator *allocator) const {
- TryNode *nd = allocator->GetMemPool()->New(allocator);
+ TryNode *CloneTree(MapleAllocator &allocator) const {
+ TryNode *nd = allocator.GetMemPool()->New(&allocator);
nd->SetStmtID(stmtIDNext++);
for (size_t i = 0; i < offsets.size(); i++) {
nd->AddOffset(offsets[i]);
@@ -1729,8 +1704,8 @@ class CatchNode : public StmtNode {
exceptionTyIdxVec.push_back(idx);
}
- CatchNode *CloneTree(MapleAllocator *allocator) const {
- CatchNode *j = allocator->GetMemPool()->New(allocator);
+ CatchNode *CloneTree(MapleAllocator &allocator) const {
+ CatchNode *j = allocator.GetMemPool()->New(&allocator);
j->SetStmtID(stmtIDNext++);
for (uint32 i = 0; i < Size(); i++) {
j->PushBack(GetExceptionTyIdxVecElement(i));
@@ -1774,8 +1749,8 @@ class SwitchNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- SwitchNode *CloneTree(MapleAllocator *allocator) const {
- SwitchNode *nd = allocator->GetMemPool()->New(allocator, this);
+ SwitchNode *CloneTree(MapleAllocator &allocator) const {
+ SwitchNode *nd = allocator.GetMemPool()->New(&allocator, this);
nd->SetSwitchOpnd(switchOpnd->CloneTree(allocator));
for (size_t i = 0; i < switchTable.size(); i++) {
nd->GetSwitchTable().push_back(switchTable[i]);
@@ -1860,8 +1835,8 @@ class MultiwayNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- MultiwayNode *CloneTree(MapleAllocator *allocator) const {
- MultiwayNode *nd = allocator->GetMemPool()->New(allocator, this);
+ MultiwayNode *CloneTree(MapleAllocator &allocator) const {
+ MultiwayNode *nd = allocator.GetMemPool()->New(&allocator, this);
nd->multiWayOpnd = static_cast(multiWayOpnd->CloneTree(allocator));
for (size_t i = 0; i < multiWayTable.size(); i++) {
BaseNode *node = multiWayTable[i].first->CloneTree(allocator);
@@ -1920,8 +1895,8 @@ class UnaryStmtNode : public StmtNode {
return uopnd->Verify();
}
- UnaryStmtNode *CloneTree(MapleAllocator *allocator) const {
- UnaryStmtNode *nd = allocator->GetMemPool()->New(*this);
+ UnaryStmtNode *CloneTree(MapleAllocator &allocator) const {
+ UnaryStmtNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(uopnd->CloneTree(allocator));
return nd;
@@ -1972,8 +1947,8 @@ class DassignNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- DassignNode *CloneTree(MapleAllocator *allocator) const {
- DassignNode *nd = allocator->GetMemPool()->New(*this);
+ DassignNode *CloneTree(MapleAllocator &allocator) const {
+ DassignNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
@@ -2036,8 +2011,8 @@ class RegassignNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- RegassignNode *CloneTree(MapleAllocator *allocator) const {
- RegassignNode *nd = allocator->GetMemPool()->New(*this);
+ RegassignNode *CloneTree(MapleAllocator &allocator) const {
+ RegassignNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
@@ -2089,8 +2064,8 @@ class CondGotoNode : public UnaryStmtNode {
offset = offsetValue;
}
- CondGotoNode *CloneTree(MapleAllocator *allocator) const {
- CondGotoNode *nd = allocator->GetMemPool()->New(*this);
+ CondGotoNode *CloneTree(MapleAllocator &allocator) const {
+ CondGotoNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
@@ -2123,8 +2098,8 @@ class RangegotoNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- RangegotoNode *CloneTree(MapleAllocator *allocator) const {
- RangegotoNode *nd = allocator->GetMemPool()->New(allocator, this);
+ RangegotoNode *CloneTree(MapleAllocator &allocator) const {
+ RangegotoNode *nd = allocator.GetMemPool()->New(&allocator, this);
nd->SetOpnd(Opnd()->CloneTree(allocator));
for (size_t i = 0; i < rangegotoTable.size(); i++) {
nd->rangegotoTable.push_back(rangegotoTable[i]);
@@ -2187,8 +2162,8 @@ class BlockNode : public StmtNode {
Dump(mod, indent, nullptr, nullptr, false, false);
}
- BlockNode *CloneTree(MapleAllocator *allocator) const {
- BlockNode *blk = allocator->GetMemPool()->New();
+ BlockNode *CloneTree(MapleAllocator &allocator) const {
+ BlockNode *blk = allocator.GetMemPool()->New();
blk->SetStmtID(stmtIDNext++);
for (auto &stmt : stmtNodeList) {
StmtNode *newStmt = static_cast(stmt.CloneTree(allocator));
@@ -2201,8 +2176,8 @@ class BlockNode : public StmtNode {
}
BlockNode *CloneTreeWithSrcPosition(const MIRModule *mod) {
- MapleAllocator *allocator = mod->CurFuncCodeMemPoolAllocator();
- BlockNode *blk = allocator->GetMemPool()->New();
+ MapleAllocator &allocator = mod->GetCurFuncCodeMPAllocator();
+ BlockNode *blk = allocator.GetMemPool()->New();
blk->SetStmtID(stmtIDNext++);
for (auto &stmt : stmtNodeList) {
StmtNode *newStmt = static_cast(stmt.CloneTree(allocator));
@@ -2270,8 +2245,8 @@ class IfStmtNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IfStmtNode *CloneTree(MapleAllocator *allocator) const {
- IfStmtNode *nd = allocator->GetMemPool()->New(*this);
+ IfStmtNode *CloneTree(MapleAllocator &allocator) const {
+ IfStmtNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
nd->thenPart = thenPart->CloneTree(allocator);
@@ -2332,8 +2307,8 @@ class WhileStmtNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- WhileStmtNode *CloneTree(MapleAllocator *allocator) const {
- WhileStmtNode *nd = allocator->GetMemPool()->New(*this);
+ WhileStmtNode *CloneTree(MapleAllocator &allocator) const {
+ WhileStmtNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
nd->body = body->CloneTree(allocator);
@@ -2371,8 +2346,8 @@ class DoloopNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- DoloopNode *CloneTree(MapleAllocator *allocator) const {
- DoloopNode *nd = allocator->GetMemPool()->New(*this);
+ DoloopNode *CloneTree(MapleAllocator &allocator) const {
+ DoloopNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetStartExpr(startExpr->CloneTree(allocator));
nd->SetContExpr(GetCondExpr()->CloneTree(allocator));
@@ -2515,8 +2490,8 @@ class ForeachelemNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- ForeachelemNode *CloneTree(MapleAllocator *allocator) const {
- ForeachelemNode *nd = allocator->GetMemPool()->New(*this);
+ ForeachelemNode *CloneTree(MapleAllocator &allocator) const {
+ ForeachelemNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetLoopBody(loopBody->CloneTree(allocator));
return nd;
@@ -2537,8 +2512,8 @@ class BinaryStmtNode : public StmtNode, public BinaryOpnds {
void Dump(const MIRModule *mod, int32 indent) const;
virtual bool Verify() const;
- BinaryStmtNode *CloneTree(MapleAllocator *allocator) const {
- BinaryStmtNode *nd = allocator->GetMemPool()->New(*this);
+ BinaryStmtNode *CloneTree(MapleAllocator &allocator) const {
+ BinaryStmtNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
@@ -2583,8 +2558,8 @@ class IassignoffNode : public BinaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IassignoffNode *CloneTree(MapleAllocator *allocator) const {
- IassignoffNode *nd = allocator->GetMemPool()->New(*this);
+ IassignoffNode *CloneTree(MapleAllocator &allocator) const {
+ IassignoffNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetBOpnd(GetBOpnd(0)->CloneTree(allocator), 0);
nd->SetBOpnd(GetBOpnd(1)->CloneTree(allocator), 1);
@@ -2608,8 +2583,8 @@ class IassignFPoffNode : public UnaryStmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
bool Verify() const;
- IassignFPoffNode *CloneTree(MapleAllocator *allocator) const {
- IassignFPoffNode *nd = allocator->GetMemPool()->New(*this);
+ IassignFPoffNode *CloneTree(MapleAllocator &allocator) const {
+ IassignFPoffNode *nd = allocator.GetMemPool()->New(*this);
nd->SetStmtID(stmtIDNext++);
nd->SetOpnd(Opnd()->CloneTree(allocator));
return nd;
@@ -2647,8 +2622,8 @@ class NaryStmtNode : public StmtNode, public NaryOpnds {
void Dump(const MIRModule *mod, int32 indent) const;
virtual bool Verify() const;
- NaryStmtNode *CloneTree(MapleAllocator *allocator) const {
- NaryStmtNode *nd = allocator->GetMemPool()->New(allocator, this);
+ NaryStmtNode *CloneTree(MapleAllocator &allocator) const {
+ NaryStmtNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -2728,8 +2703,8 @@ class CallNode : public NaryStmtNode {
bool Verify() const;
MIRType *GetCallReturnType();
- CallNode *CloneTree(MapleAllocator *allocator) const {
- CallNode *nd = allocator->GetMemPool()->New(allocator, this);
+ CallNode *CloneTree(MapleAllocator &allocator) const {
+ CallNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -2830,8 +2805,8 @@ class IcallNode : public NaryStmtNode {
virtual void Dump(const MIRModule *mod, int32 indent, bool newline) const;
bool Verify() const;
MIRType *GetCallReturnType();
- IcallNode *CloneTree(MapleAllocator *allocator) const {
- IcallNode *nd = allocator->GetMemPool()->New(allocator, this);
+ IcallNode *CloneTree(MapleAllocator &allocator) const {
+ IcallNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -2912,8 +2887,8 @@ class IntrinsiccallNode : public NaryStmtNode {
bool Verify() const;
MIRType *GetCallReturnType();
- IntrinsiccallNode *CloneTree(MapleAllocator *allocator) const {
- IntrinsiccallNode *nd = allocator->GetMemPool()->New(allocator, this);
+ IntrinsiccallNode *CloneTree(MapleAllocator &allocator) const {
+ IntrinsiccallNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -3002,8 +2977,8 @@ class CallinstantNode : public CallNode {
Dump(mod, indent, true);
}
- CallinstantNode *CloneTree(MapleAllocator *allocator) const {
- CallinstantNode *nd = allocator->GetMemPool()->New(allocator, this);
+ CallinstantNode *CloneTree(MapleAllocator &allocator) const {
+ CallinstantNode *nd = allocator.GetMemPool()->New(&allocator, this);
for (size_t i = 0; i < GetNopndSize(); i++) {
nd->GetNopnd().push_back(GetNopndAt(i)->CloneTree(allocator));
}
@@ -3047,8 +3022,8 @@ class LabelNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- LabelNode *CloneTree(MapleAllocator *allocator) const {
- LabelNode *l = allocator->GetMemPool()->New(*this);
+ LabelNode *CloneTree(MapleAllocator &allocator) const {
+ LabelNode *l = allocator.GetMemPool()->New(*this);
l->SetStmtID(stmtIDNext++);
return l;
}
@@ -3088,8 +3063,8 @@ class CommentNode : public StmtNode {
void Dump(const MIRModule *mod, int32 indent) const;
- CommentNode *CloneTree(MapleAllocator *allocator) const {
- CommentNode *c = allocator->GetMemPool()->New(allocator, this);
+ CommentNode *CloneTree(MapleAllocator &allocator) const {
+ CommentNode *c = allocator.GetMemPool()->New(&allocator, this);
return c;
}
diff --git a/src/maple_ir/include/mir_preg.h b/src/maple_ir/include/mir_preg.h
old mode 100644
new mode 100755
index 65b7728c3cf1ceb53224f8f1efa24be9155d0e58..023db68511e48af6dc416271c74cd17a9d956192
--- a/src/maple_ir/include/mir_preg.h
+++ b/src/maple_ir/include/mir_preg.h
@@ -125,7 +125,7 @@ class MIRPregTable {
}
PregIdx CreateRefPreg(MIRType *mirType) {
- ASSERT(mirType->GetPrimType() == PTY_ref || mirType->GetPrimType() == PTY_ptr, "ref or ptr type");
+ ASSERT(mirType->GetPrimType() == PTY_ref, "only ref type needed");
PregIdx idx = CreatePreg(mirType->GetPrimType());
pregTable[idx]->SetMIRType(mirType);
return idx;
diff --git a/src/maple_ir/include/option.h b/src/maple_ir/include/option.h
index 5ac115f5858b37f95f15356809a271c1974a7faf..55b7ce80318246481022b64ac96f6be91bfa0955 100644
--- a/src/maple_ir/include/option.h
+++ b/src/maple_ir/include/option.h
@@ -25,7 +25,7 @@ namespace maple {
class Options {
public:
- explicit Options(maple::MemPool *memPool) : optionAlloc(memPool) {}
+ explicit Options(maple::MemPool &memPool) : optionAlloc(&memPool) {}
bool ParseOptions(int argc, char **argv, std::string &fileName);
~Options() {}
diff --git a/src/maple_ir/src/mir_builder.cpp b/src/maple_ir/src/mir_builder.cpp
index f73b0360cf8202e4626c7280845788e097372ce5..12c371d60bb8b089903994aa4055ee06e8625702 100644
--- a/src/maple_ir/src/mir_builder.cpp
+++ b/src/maple_ir/src/mir_builder.cpp
@@ -18,42 +18,35 @@
namespace maple {
// This is for compiler-generated metadata 1-level struct
-void MIRBuilder::AddIntFieldConst(const MIRStructType *sType, MIRAggConst *newConst, uint32 fieldID, int64 constValue) {
- if (sType != nullptr && newConst != nullptr) {
- MIRConst *fieldConst = mirModule->GetMemPool()->New(constValue,
- sType->GetElemType(fieldID - 1), fieldID);
- newConst->GetConstVec().push_back(fieldConst);
- }
+void MIRBuilder::AddIntFieldConst(const MIRStructType &sType, MIRAggConst &newConst, uint32 fieldID, int64 constValue) {
+ MIRConst *fieldConst = mirModule->GetMemPool()->New(constValue, sType.GetElemType(fieldID - 1), fieldID);
+ newConst.GetConstVec().push_back(fieldConst);
}
// This is for compiler-generated metadata 1-level struct
-void MIRBuilder::AddAddrofFieldConst(const MIRStructType *structType, MIRAggConst *newConst, uint32 fieldID,
- const MIRSymbol *fieldSymbol) {
- if (structType != nullptr && newConst != nullptr && fieldSymbol != nullptr) {
- AddrofNode *fieldExpr = CreateExprAddrof(0, fieldSymbol, mirModule->GetMemPool());
- MIRConst *fieldConst = mirModule->GetMemPool()->New(fieldExpr->GetStIdx(), fieldExpr->GetFieldID(),
- structType->GetElemType(fieldID - 1));
- fieldConst->SetFieldID(fieldID);
- newConst->GetConstVec().push_back(fieldConst);
- }
+void MIRBuilder::AddAddrofFieldConst(const MIRStructType &structType, MIRAggConst &newConst, uint32 fieldID,
+ const MIRSymbol &fieldSymbol) {
+ AddrofNode *fieldExpr = CreateExprAddrof(0, &fieldSymbol, mirModule->GetMemPool());
+ MIRConst *fieldConst = mirModule->GetMemPool()->New(fieldExpr->GetStIdx(), fieldExpr->GetFieldID(),
+ structType.GetElemType(fieldID - 1));
+ fieldConst->SetFieldID(fieldID);
+ newConst.GetConstVec().push_back(fieldConst);
}
// This is for compiler-generated metadata 1-level struct
-void MIRBuilder::AddAddroffuncFieldConst(const MIRStructType *structType, MIRAggConst *newConst, uint32 fieldID,
- const MIRSymbol *funcSymbol) {
- if (structType != nullptr && newConst != nullptr && funcSymbol != nullptr) {
- MIRConst *fieldConst = nullptr;
- MIRFunction *vMethod = funcSymbol->GetFunction();
- if (vMethod->IsAbstract()) {
- fieldConst = mirModule->GetMemPool()->New(0, structType->GetElemType(fieldID - 1), fieldID);
- } else {
- AddroffuncNode *addrofFuncExpr =
- CreateExprAddroffunc(funcSymbol->GetFunction()->GetPuidx(), mirModule->GetMemPool());
- fieldConst = mirModule->GetMemPool()->New(addrofFuncExpr->GetPUIdx(),
- structType->GetElemType(fieldID - 1), fieldID);
- }
- newConst->GetConstVec().push_back(fieldConst);
+void MIRBuilder::AddAddroffuncFieldConst(const MIRStructType &structType, MIRAggConst &newConst, uint32 fieldID,
+ const MIRSymbol &funcSymbol) {
+ MIRConst *fieldConst = nullptr;
+ MIRFunction *vMethod = funcSymbol.GetFunction();
+ if (vMethod->IsAbstract()) {
+ fieldConst = mirModule->GetMemPool()->New(0, structType.GetElemType(fieldID - 1), fieldID);
+ } else {
+ AddroffuncNode *addrofFuncExpr =
+ CreateExprAddroffunc(funcSymbol.GetFunction()->GetPuidx(), mirModule->GetMemPool());
+ fieldConst = mirModule->GetMemPool()->New(addrofFuncExpr->GetPUIdx(),
+ structType.GetElemType(fieldID - 1), fieldID);
}
+ newConst.GetConstVec().push_back(fieldConst);
}
// fieldID is continuously being updated during traversal;
diff --git a/src/maple_ir/src/mir_lower.cpp b/src/maple_ir/src/mir_lower.cpp
index e4f925ee340560c04820a88b26e162272c4afb07..a61c4f14a751c321f7b4fe4f0c0ab5e9f47d758a 100644
--- a/src/maple_ir/src/mir_lower.cpp
+++ b/src/maple_ir/src/mir_lower.cpp
@@ -133,7 +133,7 @@ BlockNode *MIRLower::LowerWhileStmt(WhileStmtNode *whileStmt) {
ASSERT(whileStmt->GetBody(), "null ptr check");
blk->AppendStatementsFromBlock(whileStmt->GetBody());
CondGotoNode *brTrueStmt = mirModule.CurFuncCodeMemPool()->New(OP_brtrue);
- brTrueStmt->SetOpnd(whileStmt->Opnd()->CloneTree(mirModule.CurFuncCodeMemPoolAllocator()));
+ brTrueStmt->SetOpnd(whileStmt->Opnd()->CloneTree(mirModule.GetCurFuncCodeMPAllocator()));
brTrueStmt->SetOffset(bodyLableIdx);
blk->AddStatement(brTrueStmt);
lableStmt = mirModule.CurFuncCodeMemPool()->New();
@@ -214,7 +214,7 @@ BlockNode *MIRLower::LowerDoloopStmt(DoloopNode *doloop) {
blk->AddStatement(endDassign);
}
CondGotoNode *brTrueStmt = mirModule.CurFuncCodeMemPool()->New(OP_brtrue);
- brTrueStmt->SetOpnd(doloop->GetCondExpr()->CloneTree(mirModule.CurFuncCodeMemPoolAllocator()));
+ brTrueStmt->SetOpnd(doloop->GetCondExpr()->CloneTree(mirModule.GetCurFuncCodeMPAllocator()));
brTrueStmt->SetOffset(bodyLabelIdx);
blk->AddStatement(brTrueStmt);
labelStmt = mirModule.CurFuncCodeMemPool()->New();
diff --git a/src/maple_ir/src/mir_module.cpp b/src/maple_ir/src/mir_module.cpp
index 0a41d25ea6cde725b42e8d92ec0f1f627f0e5820..b8bc8a1e66aad8b5606eea176aaee1bebb60a7a9 100644
--- a/src/maple_ir/src/mir_module.cpp
+++ b/src/maple_ir/src/mir_module.cpp
@@ -53,7 +53,6 @@ MIRModule::MIRModule(const char *fn)
entryFunc(nullptr),
floatNum(0),
optimizedFuncs(memPoolAllocator.Adapter()),
- rcNotNeedingLock(memPoolAllocator.Adapter()),
puIdxFieldInitializedMap(std::less(), memPoolAllocator.Adapter()) {
flavor = kFlavorUnknown;
srcLang = kSrcLangUnknown;
@@ -91,6 +90,10 @@ MapleAllocator *MIRModule::CurFuncCodeMemPoolAllocator(void) const {
return curFunction->GetCodeMempoolAllocator();
}
+MapleAllocator &MIRModule::GetCurFuncCodeMPAllocator(void) const {
+ return curFunction->GetCodeMPAllocator();
+}
+
void MIRModule::AddExternStructType(TyIdx tyIdx) {
externStructTypeSet.insert(tyIdx);
}
diff --git a/src/maple_ir/src/mir_nodes.cpp b/src/maple_ir/src/mir_nodes.cpp
index c7cc985cfbfd229d49ddd7d2fc4c1fdce84a7a2d..ee9d3999e5f55db8818b88dc03710818e3d5f63a 100644
--- a/src/maple_ir/src/mir_nodes.cpp
+++ b/src/maple_ir/src/mir_nodes.cpp
@@ -136,11 +136,6 @@ bool AddrofNode::CheckNode(const MIRModule *mod) const {
}
}
-bool AddrofNode::HasSymbol(MIRModule *mod, MIRSymbol *st) {
- ASSERT(mod != nullptr, "mod is null");
- return st == mod->CurFunction()->GetLocalOrGlobalSymbol(GetStIdx());
-}
-
void BlockNode::AddStatement(StmtNode *stmt) {
ASSERT(stmt != nullptr, "null ptr check");
stmtNodeList.push_back(stmt);
diff --git a/src/maple_me/include/alias_analysis_table.h b/src/maple_me/include/alias_analysis_table.h
index 839193628f4c1f1ca3579f5eb526b2d7f08543fe..9c0df567d6c4d5092fe2f2e6d4cfe1bf271a7f28 100644
--- a/src/maple_me/include/alias_analysis_table.h
+++ b/src/maple_me/include/alias_analysis_table.h
@@ -16,36 +16,38 @@
#define MAPLE_ME_INCLUDE_ALIAS_ANALYSIS_TABLE_H
#include "orig_symbol.h"
#include "ssa_tab.h"
+#include "class_hierarchy.h"
namespace maple {
class AliasAnalysisTable {
public:
- AliasAnalysisTable(SSATab *ssaTable, MapleAllocator allocator, MIRModule *module)
+ AliasAnalysisTable(SSATab &ssaTable, MapleAllocator allocator, MIRModule &module, KlassHierarchy &kh)
: ssaTab(ssaTable),
alloc(allocator),
mirModule(module),
prevLevelNode(alloc.Adapter()),
nextLevelNodes(alloc.Adapter()),
- memPool(ssaTab->GetMempool()) {}
+ memPool(ssaTab.GetMempool()),
+ klassHierarchy(kh) {}
- OriginalSt *GetPrevLevelNode(const OriginalSt *ost);
- MapleVector *GetNextLevelNodes(const OriginalSt *ost);
- OriginalSt *FindOrCreateAddrofSymbolOriginalSt(const OriginalSt *ost);
- OriginalSt *FindOrCreateExtraLevSymOrRegOriginalSt(OriginalSt *ost, TyIdx ptyidx, FieldID fld);
- OriginalSt *FindOrCreateExtraLevOriginalSt(OriginalSt *ost, TyIdx ptyidx, FieldID fld);
+ OriginalSt *GetPrevLevelNode(const OriginalSt &ost);
+ MapleVector *GetNextLevelNodes(const OriginalSt &ost);
+ OriginalSt *FindOrCreateAddrofSymbolOriginalSt(const OriginalSt &ost);
+ OriginalSt *FindOrCreateExtraLevSymOrRegOriginalSt(OriginalSt &ost, TyIdx ptyidx, FieldID fld);
+ OriginalSt *FindOrCreateExtraLevOriginalSt(OriginalSt &ost, TyIdx ptyidx, FieldID fld);
OriginalSt *FindExtraLevOriginalSt(const MapleVector &nextLevelOsts, FieldID fld);
- OriginalSt *FindOrCreateDiffFieldOriginalSt(const OriginalSt *ost, FieldID fld);
- OriginalSt *FindDiffFieldOriginalSt(const OriginalSt *ost, FieldID fld);
+ OriginalSt *FindOrCreateDiffFieldOriginalSt(const OriginalSt &ost, FieldID fld);
+ OriginalSt *FindDiffFieldOriginalSt(const OriginalSt &ost, FieldID fld);
~AliasAnalysisTable() = default;
private:
- SSATab *ssaTab;
+ SSATab &ssaTab;
MapleAllocator alloc;
- MIRModule *mirModule;
+ MIRModule &mirModule;
MapleMap prevLevelNode; // index is the OStIdx
MapleMap*> nextLevelNodes; // index is the OStIdx
MemPool *memPool;
+ KlassHierarchy &klassHierarchy;
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ALIAS_ANALYSIS_TABLE_H
diff --git a/src/maple_me/include/alias_class.h b/src/maple_me/include/alias_class.h
index 5291513affe74eda63fafae6848bf28bd93e089f..3903745f7a5d625a8dfac549359aba28cc4d2908 100644
--- a/src/maple_me/include/alias_class.h
+++ b/src/maple_me/include/alias_class.h
@@ -24,8 +24,9 @@
namespace maple {
class AliasElem {
+ friend class AliasClass;
public:
- AliasElem(uint32 i, OriginalSt *origst)
+ AliasElem(uint32 i, OriginalSt &origst)
: id(i),
ost(origst),
notAllDefsSeen(false),
@@ -35,13 +36,13 @@ class AliasElem {
~AliasElem() {}
- void Dump(MIRModule *mod) const;
+ void Dump(MIRModule &mod) const;
uint32 GetClassID() const {
return id;
}
- OriginalSt *GetOriginalSt() const {
+ OriginalSt &GetOriginalSt() const {
return ost;
}
@@ -61,25 +62,23 @@ class AliasElem {
nextLevNotAllDefsSeen = allDefsSeen;
}
- MapleSet *GetClassSet() const {
+ const MapleSet *GetClassSet() const {
return classSet;
}
-
- void SetClassSet(MapleSet *set) {
- classSet = set;
+ void AddClassToSet(uint id) {
+ classSet->emplace(id);
}
- MapleSet *GetAssignSet() const {
+ const MapleSet *GetAssignSet() const {
return assignSet;
}
-
- void SetAssignSet(MapleSet *set) {
- assignSet = set;
+ void AddAssignToSet(uint id) {
+ assignSet->emplace(id);
}
private:
uint32 id; // the original alias class id, before any union; start from 0
- OriginalSt *ost;
+ OriginalSt &ost;
bool notAllDefsSeen; // applied to current level; unused for lev -1
bool nextLevNotAllDefsSeen; // remember that next level's elements need to be made notAllDefsSeen
MapleSet *classSet; // points to the set of members of its class; nullptr for single-member classes
@@ -88,15 +87,15 @@ class AliasElem {
class AliasClass : public AnalysisResult {
public:
- AliasClass(MemPool *memPool, MIRModule *mod, SSATab *ssatb, bool lessThrowAliasParam, bool finalFieldHasAlias,
+ AliasClass(MemPool &memPool, MIRModule &mod, SSATab &ssatb, bool lessThrowAliasParam, bool finalFieldHasAlias,
bool ignoreIpa, bool setCalleeHasSideEffect = false, KlassHierarchy *kh = nullptr)
- : AnalysisResult(memPool),
+ : AnalysisResult(&memPool),
mirModule(mod),
acMemPool(memPool),
- acAlloc(memPool),
+ acAlloc(&memPool),
ssaTab(ssatb),
unionFind(memPool),
- osym2Elem(ssatb->GetOriginalStTableSize(), nullptr, acAlloc.Adapter()),
+ osym2Elem(ssatb.GetOriginalStTableSize(), nullptr, acAlloc.Adapter()),
id2Elem(acAlloc.Adapter()),
notAllDefsSeenClassSetRoots(acAlloc.Adapter()),
globalsAffectedByCalls(std::less(), acAlloc.Adapter()),
@@ -112,13 +111,13 @@ class AliasClass : public AnalysisResult {
AliasAnalysisTable *GetAliasAnalysisTable() {
if (aliasAnalysisTable == nullptr) {
- aliasAnalysisTable = acMemPool->New(ssaTab, acAlloc, mirModule);
+ aliasAnalysisTable = acMemPool.New(ssaTab, acAlloc, mirModule, *klassHierarchy);
}
return aliasAnalysisTable;
}
- AliasElem *FindAliasElem(const OriginalSt *ost) const {
- return osym2Elem.at(ost->GetIndex().idx);
+ AliasElem *FindAliasElem(const OriginalSt &ost) const {
+ return osym2Elem.at(ost.GetIndex().idx);
}
size_t GetAliasElemCount() const {
@@ -129,41 +128,41 @@ class AliasClass : public AnalysisResult {
return id2Elem.at(id);
}
- bool IsCreatedByElimRC(const OriginalSt *ost) const {
- return ost->GetIndex().idx >= osym2Elem.size();
+ bool IsCreatedByElimRC(const OriginalSt &ost) const {
+ return ost.GetIndex().idx >= osym2Elem.size();
}
void ReinitUnionFind() {
unionFind.Reinit();
}
- void ApplyUnionForCopies(StmtNode *stmt);
+ void ApplyUnionForCopies(StmtNode &stmt);
void CreateAssignSets();
void DumpAssignSets();
void UnionAllPointedTos();
void ApplyUnionForPointedTos();
- void CollectRootIDOfNextLevelNodes(const OriginalSt *ost, std::set &rootIDOfNADSs);
+ void CollectRootIDOfNextLevelNodes(const OriginalSt &ost, std::set &rootIDOfNADSs);
void UnionForNotAllDefsSeen();
void CollectAliasGroups(std::map> &aliasGroups);
bool AliasAccordingToType(TyIdx tyidxA, TyIdx tyidxB);
- bool AliasAccordingToFieldID(const OriginalSt *ostA, const OriginalSt *ostB);
+ bool AliasAccordingToFieldID(const OriginalSt &ostA, const OriginalSt &ostB);
void ReconstructAliasGroups();
void CollectNotAllDefsSeenAes();
void CreateClassSets();
void DumpClassSets();
- void InsertMayDefUseCall(StmtNode *stmt, BBId bbid, bool hasSideEffect, bool hasNoPrivateDefEffect);
- void GenericInsertMayDefUse(StmtNode *stmt, BBId bbid);
+ void InsertMayDefUseCall(StmtNode &stmt, BBId bbid, bool hasSideEffect, bool hasNoPrivateDefEffect);
+ void GenericInsertMayDefUse(StmtNode &stmt, BBId bbid);
protected:
- MIRModule *mirModule;
+ MIRModule &mirModule;
virtual bool InConstructorLikeFunc() const {
return true;
}
private:
- MemPool *acMemPool;
+ MemPool &acMemPool;
MapleAllocator acAlloc;
- SSATab *ssaTab;
+ SSATab &ssaTab;
UnionFind unionFind;
MapleVector osym2Elem; // index is OStIdx
MapleVector id2Elem; // index is the id
@@ -177,47 +176,48 @@ class AliasClass : public AnalysisResult {
bool calleeHasSideEffect;
KlassHierarchy *klassHierarchy;
AliasAnalysisTable *aliasAnalysisTable;
- bool CallHasNoSideEffectOrPrivateDefEffect(StmtNode *stmt, FuncAttrKind attrKind);
- bool CallHasSideEffect(StmtNode *stmt);
- bool CallHasNoPrivateDefEffect(StmtNode *stmt);
- AliasElem *FindOrCreateAliasElem(OriginalSt *ost);
- AliasElem *FindOrCreateExtraLevAliasElem(BaseNode *expr, TyIdx tyIdx, FieldID fieldId);
- AliasElem *CreateAliasElemsExpr(BaseNode *expr);
- void SetNotAllDefsSeenForMustDefs(const StmtNode *callas);
- void SetPtrOpndNextLevNADS(const BaseNode *opnd, AliasElem *ae, bool hasNoPrivateDefEffect);
+ bool CallHasNoSideEffectOrPrivateDefEffect(StmtNode &stmt, FuncAttrKind attrKind);
+ bool CallHasSideEffect(StmtNode &stmt);
+ bool CallHasNoPrivateDefEffect(StmtNode &stmt);
+ AliasElem *FindOrCreateAliasElem(OriginalSt &ost);
+ AliasElem *FindOrCreateExtraLevAliasElem(BaseNode &expr, TyIdx tyIdx, FieldID fieldId);
+ AliasElem *CreateAliasElemsExpr(BaseNode &expr);
+ void SetNotAllDefsSeenForMustDefs(const StmtNode &callas);
+ void SetPtrOpndNextLevNADS(const BaseNode &opnd, AliasElem *ae, bool hasNoPrivateDefEffect);
void SetPtrOpndsNextLevNADS(uint start, uint end, MapleVector &opnds, bool hasNoPrivateDefEffect);
- void ApplyUnionForDassignCopy(const AliasElem *lhsAe, const AliasElem *rhsAe, const BaseNode *rhs);
+ void ApplyUnionForDassignCopy(const AliasElem &lhsAe, const AliasElem *rhsAe, const BaseNode *rhs);
AliasElem *FindOrCreateDummyNADSAe();
- void CollectMayDefForMustDefs(const StmtNode *stmt, std::set &mayDefOsts);
- void CollectMayUseForCallOpnd(const StmtNode *stmt, std::set &mayUseOsts);
- void InsertMayDefNodeForCall(std::set &mayDefOsts, MapleMap *mayDefNodes,
- StmtNode *stmt, BBId bbid, bool hasNoPrivateDefEffect);
- void InsertMayUseExpr(BaseNode *expr);
+ void CollectMayDefForMustDefs(const StmtNode &stmt, std::set &mayDefOsts);
+ void CollectMayUseForCallOpnd(const StmtNode &stmt, std::set &mayUseOsts);
+ void InsertMayDefNodeForCall(std::set &mayDefOsts, MapleMap &mayDefNodes,
+ StmtNode &stmt, BBId bbid, bool hasNoPrivateDefEffect);
+ void InsertMayUseExpr(BaseNode &expr);
void CollectMayUseFromGlobalsAffectedByCalls(std::set &mayUseOsts);
void CollectMayUseFromNADS(std::set &mayUseOsts);
- void InsertMayUseNode(std::set &mayUseOsts, MapleMap *mayUseNodes);
- void InsertMayUseReturn(const StmtNode *stmt);
- void CollectPtsToOfReturnOpnd(const OriginalSt *ost, std::set &mayUseOsts);
- void InsertReturnOpndMayUse(const StmtNode *stmt);
- void InsertMayUseAll(const StmtNode *stmt);
- void CollectMayDefForDassign(const StmtNode *stmt, std::set &mayDefOsts);
- void InsertMayDefNode(std::set &mayDefOsts, MapleMap *mayDefNodes, StmtNode *stmt,
+ void InsertMayUseNode(std::set &mayUseOsts, MapleMap &mayUseNodes);
+ void InsertMayUseReturn(const StmtNode &stmt);
+ void CollectPtsToOfReturnOpnd(const OriginalSt &ost, std::set &mayUseOsts);
+ void InsertReturnOpndMayUse(const StmtNode &stmt);
+ void InsertMayUseAll(const StmtNode &stmt);
+ void CollectMayDefForDassign(const StmtNode &stmt, std::set &mayDefOsts);
+ void InsertMayDefNode(std::set &mayDefOsts, MapleMap &mayDefNodes, StmtNode &stmt,
BBId bbid);
- void InsertMayDefDassign(StmtNode *stmt, BBId bbid);
- void CollectMayDefForIassign(StmtNode *stmt, std::set &mayDefOsts);
- void InsertMayDefNodeExcludeFinalOst(std::set &mayDefOsts, MapleMap *mayDefNodes,
- StmtNode *stmt, BBId bbid);
- void InsertMayDefIassign(StmtNode *stmt, BBId bbid);
- void InsertMayDefUseSyncOps(StmtNode *stmt, BBId bbid);
- void InsertMayUseNodeExcludeFinalOst(const std::set &mayUseOsts, MapleMap *mayUseNodes);
- void InsertMayDefUseIntrncall(StmtNode *stmt, BBId bbid);
- void InsertMayDefUseClinitCheck(IntrinsiccallNode *stmt, BBId bbid);
+ void InsertMayDefDassign(StmtNode &stmt, BBId bbid);
+ bool IsEquivalentField(TyIdx tyIdxA, FieldID fldA, TyIdx tyIdxB, FieldID fldB);
+ void CollectMayDefForIassign(StmtNode &stmt, std::set &mayDefOsts);
+ void InsertMayDefNodeExcludeFinalOst(std::set &mayDefOsts, MapleMap &mayDefNodes,
+ StmtNode &stmt, BBId bbid);
+ void InsertMayDefIassign(StmtNode &stmt, BBId bbid);
+ void InsertMayDefUseSyncOps(StmtNode &stmt, BBId bbid);
+ void InsertMayUseNodeExcludeFinalOst(const std::set &mayUseOsts,
+ MapleMap &mayUseNodes);
+ void InsertMayDefUseIntrncall(StmtNode &stmt, BBId bbid);
+ void InsertMayDefUseClinitCheck(IntrinsiccallNode &stmt, BBId bbid);
virtual BB *GetBB(BBId id) = 0;
void ProcessIdsAliasWithRoot(const std::set &idsAliasWithRoot, std::vector &newGroups);
void UpdateNextLevelNodes(std::vector &nextLevelOsts, const AliasElem &aliasElem);
void UnionNodes(std::vector &nextLevelOsts);
int GetOffset(const Klass &super, Klass &base) const;
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ALIAS_CLASS_H
diff --git a/src/maple_me/include/bb.h b/src/maple_me/include/bb.h
index cadf730d4fe77f07d96332467ef822e743094320..1cf4f1e61072e131b345b6e9927421b900ba0f0f 100644
--- a/src/maple_me/include/bb.h
+++ b/src/maple_me/include/bb.h
@@ -261,7 +261,7 @@ class BB {
void FindReachableBBs(std::vector &);
void FindWillExitBBs(std::vector &);
- PhiNode *PhiofVerStInserted(VersionSt *vsym);
+ const PhiNode *PhiofVerStInserted(VersionSt *vsym);
void InsertPhi(MapleAllocator *alloc, VersionSt *vsym);
void DumpPhi(const MIRModule*);
bool IsMeStmtEmpty() const {
@@ -393,11 +393,9 @@ class BB {
StmtNodes stmtNodeList;
MeStmts meStmtList;
};
-
} // namespace maple
namespace std {
-
template <>
struct hash {
size_t operator()(const maple::BBId &x) const {
@@ -411,7 +409,6 @@ struct hash {
return x.idx;
}
};
-
} // namespace std
-#endif // MAPLE_ME_INCLUDE_BB_H
+#endif // MAPLE_ME_INCLUDE_BB_H
\ No newline at end of file
diff --git a/src/maple_me/include/dominance.h b/src/maple_me/include/dominance.h
index f5b03cb501d779c5a6a0c80122c7af0f09d7ed99..2ff5425f8e9a306f799274950a6d921c222dab00 100644
--- a/src/maple_me/include/dominance.h
+++ b/src/maple_me/include/dominance.h
@@ -20,27 +20,27 @@
namespace maple {
class Dominance : public AnalysisResult {
public:
- Dominance(MemPool *memPool, MemPool *tmpPool, MapleVector *bbVec, BB *commonEntryBB, BB *commonExitBB)
- : AnalysisResult(memPool),
- domAllocator(memPool),
- tmpAllocator(tmpPool),
- bbVec(*bbVec),
+ Dominance(MemPool &memPool, MemPool &tmpPool, MapleVector &bbVec, BB &commonEntryBB, BB &commonExitBB)
+ : AnalysisResult(&memPool),
+ domAllocator(&memPool),
+ tmpAllocator(&tmpPool),
+ bbVec(bbVec),
commonEntryBB(commonEntryBB),
commonExitBB(commonExitBB),
- postOrderIDVec(bbVec->size(), -1, tmpAllocator.Adapter()),
+ postOrderIDVec(bbVec.size(), -1, tmpAllocator.Adapter()),
reversePostOrder(tmpAllocator.Adapter()),
- doms(bbVec->size(), nullptr, domAllocator.Adapter()),
- pdomPostOrderIDVec(bbVec->size(), -1, tmpAllocator.Adapter()),
+ doms(bbVec.size(), nullptr, domAllocator.Adapter()),
+ pdomPostOrderIDVec(bbVec.size(), -1, tmpAllocator.Adapter()),
pdomReversePostOrder(tmpAllocator.Adapter()),
- pdoms(bbVec->size(), nullptr, domAllocator.Adapter()),
- domFrontier(bbVec->size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
- domChildren(bbVec->size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
- dtPreOrder(bbVec->size(), BBId(0), domAllocator.Adapter()),
- dtDfn(bbVec->size(), -1, domAllocator.Adapter()),
- pdomFrontier(bbVec->size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
- pdomChildren(bbVec->size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
- pdtPreOrder(bbVec->size(), BBId(0), domAllocator.Adapter()),
- pdtDfn(bbVec->size(), -1, domAllocator.Adapter()) {}
+ pdoms(bbVec.size(), nullptr, domAllocator.Adapter()),
+ domFrontier(bbVec.size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
+ domChildren(bbVec.size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
+ dtPreOrder(bbVec.size(), BBId(0), domAllocator.Adapter()),
+ dtDfn(bbVec.size(), -1, domAllocator.Adapter()),
+ pdomFrontier(bbVec.size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
+ pdomChildren(bbVec.size(), MapleSet(std::less(), domAllocator.Adapter()), domAllocator.Adapter()),
+ pdtPreOrder(bbVec.size(), BBId(0), domAllocator.Adapter()),
+ pdtDfn(bbVec.size(), -1, domAllocator.Adapter()) {}
~Dominance() = default;
@@ -48,23 +48,22 @@ class Dominance : public AnalysisResult {
void ComputeDominance();
void ComputeDomFrontiers();
void ComputeDomChildren();
- void ComputeDtPreorder(const BB *bb, size_t &num);
+ void ComputeDtPreorder(const BB &bb, size_t &num);
void ComputeDtDfn();
- bool Dominate(const BB *b1, BB *b2); // true if b1 dominates b2
+ bool Dominate(const BB &b1, BB &b2); // true if b1 dominates b2
void DumpDoms();
void PdomGenPostOrderID();
void ComputePostDominance();
void ComputePdomFrontiers();
void ComputePdomChildren();
- void ComputePdtPreorder(const BB *bb, size_t &num);
+ void ComputePdtPreorder(const BB &bb, size_t &num);
void ComputePdtDfn();
- bool PostDominate(const BB *b1, BB *b2); // true if b1 postdominates b2
+ bool PostDominate(const BB &b1, BB &b2); // true if b1 postdominates b2
void DumpPdoms();
MapleVector &GetBBVec() {
return bbVec;
}
-
const MapleVector &GetBBVec() const {
return bbVec;
}
@@ -81,22 +80,14 @@ class Dominance : public AnalysisResult {
return bbVec[i];
}
- BB *GetCommonEntryBB() {
+ BB &GetCommonEntryBB() {
return commonEntryBB;
}
- void SetCommonEntryBB(BB *bb) {
- commonEntryBB = bb;
- }
-
- BB *GetCommonExitBB() {
+ BB &GetCommonExitBB() {
return commonExitBB;
}
- void SetCommonExitBB(BB *exitBB) {
- commonExitBB = exitBB;
- }
-
MapleVector &GetPostOrderIDVec() {
return postOrderIDVec;
}
@@ -206,8 +197,8 @@ class Dominance : public AnalysisResult {
private:
MapleAllocator tmpAllocator; // can be freed after dominator computation
MapleVector &bbVec;
- BB *commonEntryBB;
- BB *commonExitBB;
+ BB &commonEntryBB;
+ BB &commonExitBB;
MapleVector postOrderIDVec; // index is bb id
MapleVector reversePostOrder; // an ordering of the BB in reverse postorder
MapleVector doms; // index is bb id; immediate dominator for each BB
@@ -225,12 +216,11 @@ class Dominance : public AnalysisResult {
MapleVector pdtDfn; // gives position of each BB in pdt_preorder
protected:
- void PostOrderWalk(BB *bb, int32 &pid, std::vector &visitedMap);
- BB *Intersect(BB *bb1, const BB *bb2);
- bool CommonEntryBBIsPred(const BB *bb);
- void PdomPostOrderWalk(BB *bb, int32 &pid, std::vector &visitedMap);
- BB *PdomIntersect(BB *bb1, const BB *bb2);
+ void PostOrderWalk(BB &bb, int32 &pid, std::vector &visitedMap);
+ BB *Intersect(BB &bb1, const BB &bb2);
+ bool CommonEntryBBIsPred(const BB &bb);
+ void PdomPostOrderWalk(BB &bb, int32 &pid, std::vector &visitedMap);
+ BB *PdomIntersect(BB &bb1, const BB &bb2);
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_DOMINANCE_H
diff --git a/src/maple_me/include/func_emit.h b/src/maple_me/include/func_emit.h
index 0d28328ff93f550eb06180d70c40d59148b0bcc7..a3e7a29ae4131c819935441fc2f3f99cdf146558 100644
--- a/src/maple_me/include/func_emit.h
+++ b/src/maple_me/include/func_emit.h
@@ -20,12 +20,11 @@
namespace maple {
class FuncEmit {
public:
- void EmitBeforeHSSA(MIRFunction *func, const MapleVector &bbList);
+ void EmitBeforeHSSA(MIRFunction &func, const MapleVector &bbList);
virtual ~FuncEmit() = default;
private:
- void EmitLabelForBB(MIRFunction *func, BB *bb);
+ void EmitLabelForBB(MIRFunction &func, BB &bb);
};
-
} // namespace maple
-#endif // MAPLE_ME_INCLUDE_FUNC_EMIT_H
+#endif // MAPLE_ME_INCLUDE_FUNC_EMIT_H
\ No newline at end of file
diff --git a/src/maple_me/include/irmap.h b/src/maple_me/include/irmap.h
index fae859984cddcc40da3c4da76e80907e430c9051..9a8320063fe28f41e41e7275c8529aea273b688d 100644
--- a/src/maple_me/include/irmap.h
+++ b/src/maple_me/include/irmap.h
@@ -23,19 +23,17 @@
namespace maple {
class IRMap : public AnalysisResult {
public:
- IRMap(SSATab *ssatab, Dominance *dom, MemPool *memPool, MemPool *tmpMemPool, uint32 hashTableSize)
- : AnalysisResult(memPool),
+ IRMap(SSATab &ssatab, Dominance &dom, MemPool &memPool, MemPool &tmpMemPool, uint32 hashTableSize)
+ : AnalysisResult(&memPool),
ssaTab(ssatab),
- mirModule(&ssatab->mirModule),
+ mirModule(ssatab.GetModule()),
dom(dom),
- irMapAlloc(memPool),
- tempAlloc(tmpMemPool),
- exprID(0),
+ irMapAlloc(&memPool),
+ tempAlloc(&tmpMemPool),
mapHashLength(hashTableSize),
hashTable(mapHashLength, nullptr, irMapAlloc.Adapter()),
- verst2MeExprTable(ssaTab->GetVersionStTableSize(), nullptr, irMapAlloc.Adapter()),
+ verst2MeExprTable(ssaTab.GetVersionStTableSize(), nullptr, irMapAlloc.Adapter()),
regMeExprTable(irMapAlloc.Adapter()),
- needAnotherPass(false),
curBB(nullptr) {}
virtual ~IRMap() {}
@@ -43,38 +41,38 @@ class IRMap : public AnalysisResult {
virtual BB *GetBB(BBId id) = 0;
virtual BB *GetBBForLabIdx(LabelIdx lidx, PUIdx pidx = 0) = 0;
Dominance *GetDominance() {
- return dom;
- }
-
- MeExpr *HashMeExpr(MeExpr *meExpr);
- void PutToBucket(uint32, MeExpr*);
- void BuildBB(BB *bb, std::vector &bbIRMapProcessed);
- void BuildAssertMeStmt(NaryMeExpr*);
- MeStmt *BuildMeStmtWithNoSSAPart(StmtNode *stmt);
- MeStmt *BuildMeStmt(StmtNode*);
- MeExpr *BuildExpr(BaseNode*);
- MeExpr *BuildLHSVar(const VersionSt *verSt, DassignMeStmt *defMeStmt, DassignNode *dassign);
- MeExpr *BuildLHSReg(const VersionSt *verSt, RegassignMeStmt *defMeStmt, const RegassignNode *regassign);
- IvarMeExpr *BuildLHSIvar(MeExpr *baseAddr, IassignMeStmt *iassignMeStmt, FieldID fieldID);
- IvarMeExpr *BuildLHSIvarFromIassMeStmt(IassignMeStmt *iassignMeStmt);
- RegMeExpr *CreateRefRegMeExpr(MIRSymbol*);
- RegMeExpr *CreateRegRefMeExpr(MeExpr*);
- RegMeExpr *CreateRegRefMeExpr(MIRType*);
- VarMeExpr *CreateVarMeExprVersion(const VarMeExpr*);
- MeExpr *CreateAddrofMeExpr(MeExpr*);
+ return &dom;
+ }
+
+ MeExpr *HashMeExpr(MeExpr &meExpr);
+ void PutToBucket(uint32, MeExpr&);
+ void BuildBB(BB &bb, std::vector &bbIRMapProcessed);
+ void BuildAssertMeStmt(NaryMeExpr&);
+ MeStmt *BuildMeStmtWithNoSSAPart(StmtNode &stmt);
+ MeStmt *BuildMeStmt(StmtNode&);
+ MeExpr *BuildExpr(BaseNode&);
+ MeExpr *BuildLHSVar(const VersionSt &verSt, DassignMeStmt &defMeStmt, DassignNode &dassign);
+ MeExpr *BuildLHSReg(const VersionSt &verSt, RegassignMeStmt &defMeStmt, const RegassignNode ®assign);
+ IvarMeExpr *BuildLHSIvar(MeExpr &baseAddr, IassignMeStmt &iassignMeStmt, FieldID fieldID);
+ IvarMeExpr *BuildLHSIvarFromIassMeStmt(IassignMeStmt &iassignMeStmt);
+ RegMeExpr *CreateRefRegMeExpr(MIRSymbol&);
+ RegMeExpr *CreateRegRefMeExpr(MeExpr&);
+ RegMeExpr *CreateRegRefMeExpr(MIRType&);
+ VarMeExpr *CreateVarMeExprVersion(const VarMeExpr&);
+ MeExpr *CreateAddrofMeExpr(MeExpr&);
RegMeExpr *CreateRegMeExpr(PrimType);
- RegMeExpr *CreateRegMeExprVersion(const OriginalSt*);
- RegMeExpr *CreateRegMeExprVersion(const RegMeExpr*);
- MeExpr *ReplaceMeExprExpr(MeExpr*, MeExpr*, MeExpr*);
- bool ReplaceMeExprStmtOpnd(uint32, MeStmt*, MeExpr*, MeExpr*);
- bool ReplaceMeExprStmt(MeStmt*, MeExpr*, MeExpr*);
+ RegMeExpr *CreateRegMeExprVersion(const OriginalSt&);
+ RegMeExpr *CreateRegMeExprVersion(const RegMeExpr&);
+ MeExpr *ReplaceMeExprExpr(MeExpr&, MeExpr&, MeExpr&);
+ bool ReplaceMeExprStmtOpnd(uint32, MeStmt&, MeExpr&, MeExpr&);
+ bool ReplaceMeExprStmt(MeStmt&, MeExpr&, MeExpr&);
MeExpr *GetMeExprByVerID(uint32 verid) {
return verst2MeExprTable[verid];
}
- VarMeExpr *GetOrCreateVarFromVerSt(const VersionSt *verSt);
- VarMeExpr *GetOrCreateZeroVersionVarMeExpr(OriginalSt *oSt);
- RegMeExpr *GetOrCreateRegFromVerSt(const VersionSt *verSt);
+ VarMeExpr *GetOrCreateVarFromVerSt(const VersionSt &verSt);
+ VarMeExpr *GetOrCreateZeroVersionVarMeExpr(const OriginalSt &oSt);
+ RegMeExpr *GetOrCreateRegFromVerSt(const VersionSt &verSt);
MeExpr *GetMeExpr(size_t index) {
ASSERT(index < verst2MeExprTable.size(), "index out of range");
MeExpr *meExpr = verst2MeExprTable.at(index);
@@ -86,36 +84,36 @@ class IRMap : public AnalysisResult {
VarMeExpr *CreateNewGlobalTmp(GStrIdx strIdx, PrimType ptyp);
VarMeExpr *CreateNewLocalRefVarTmp(GStrIdx strIdx, TyIdx tIdx);
- DassignMeStmt *CreateDassignMeStmt(MeExpr*, MeExpr*, BB*);
- RegassignMeStmt *CreateRegassignMeStmt(MeExpr*, MeExpr*, BB*);
- void InsertMeStmtBefore(BB*, MeStmt*, MeStmt*);
- void BuildChiList(MeStmt*, MapleMap &, MapleMap &);
- void BuildMustDefList(MeStmt *meStmt, MapleVector &, MapleVector &);
+ DassignMeStmt *CreateDassignMeStmt(MeExpr&, MeExpr&, BB&);
+ RegassignMeStmt *CreateRegassignMeStmt(MeExpr&, MeExpr&, BB&);
+ void InsertMeStmtBefore(BB&, MeStmt&, MeStmt&);
+ void BuildChiList(MeStmt&, MapleMap &, MapleMap &);
+ void BuildMustDefList(MeStmt &meStmt, MapleVector &, MapleVector &);
void BuildMuList(MapleMap &, MapleMap &);
- void BuildPhiMeNode(BB*);
+ void BuildPhiMeNode(BB&);
VersionSt *GetVerSt(size_t veridx) const {
- return ssaTab->GetVerSt(veridx);
+ return ssaTab.GetVerSt(veridx);
}
- MeRegPhiNode *CreateMeRegPhi(RegMeExpr*);
- MeVarPhiNode *CreateMeVarPhi(VarMeExpr*);
+ MeRegPhiNode *CreateMeRegPhi(RegMeExpr&);
+ MeVarPhiNode *CreateMeVarPhi(VarMeExpr&);
bool Verify(); // iterate hash table and check with meexpr_table
- BB *GetFalseBrBB(CondGotoMeStmt*);
+ BB *GetFalseBrBB(CondGotoMeStmt&);
std::string PhaseName() const {
return "irmap";
}
virtual void Dump() = 0;
- virtual void SetCurFunction(BB *bb) {}
+ virtual void SetCurFunction(BB &bb) {}
MeExpr *CreateIntConstMeExpr(int64, PrimType);
- MeExpr *CreateConstMeExpr(PrimType, MIRConst*);
- MeExpr *CreateMeExprBinary(Opcode, PrimType, MeExpr*, MeExpr*);
- MeExpr *CreateMeExprSelect(PrimType, MeExpr*, MeExpr*, MeExpr*);
- MeExpr *CreateMeExprCompare(Opcode, PrimType, PrimType, MeExpr*, MeExpr*);
- MeExpr *CreateMeExprIntrinsiciop1(MIRIntrinsicID, PrimType, MeExpr*);
- MeExpr *CreateMeExprTypeCvt(PrimType, PrimType, MeExpr*);
- MeExpr *CreateAddrofMeExprFromNewSymbol(MIRSymbol*, PUIdx);
+ MeExpr *CreateConstMeExpr(PrimType, MIRConst&);
+ MeExpr *CreateMeExprBinary(Opcode, PrimType, MeExpr&, MeExpr&);
+ MeExpr *CreateMeExprSelect(PrimType, MeExpr&, MeExpr&, MeExpr&);
+ MeExpr *CreateMeExprCompare(Opcode, PrimType, PrimType, MeExpr&, MeExpr&);
+ MeExpr *CreateMeExprIntrinsiciop1(MIRIntrinsicID, PrimType, MeExpr&);
+ MeExpr *CreateMeExprTypeCvt(PrimType, PrimType, MeExpr&);
+ MeExpr *CreateAddrofMeExprFromNewSymbol(MIRSymbol&, PUIdx);
IntrinsiccallMeStmt *CreateIntrinsicCallMeStmt(MIRIntrinsicID idx, std::vector &opnds,
TyIdx tyidx = TyIdx());
IntrinsiccallMeStmt *CreateIntrinsicCallAssignedMeStmt(MIRIntrinsicID idx, std::vector &opnds, MeExpr *ret,
@@ -131,11 +129,11 @@ class IRMap : public AnalysisResult {
}
SSATab *GetSSATab() const {
- return ssaTab;
+ return &ssaTab;
}
MIRModule *GetMIRModule() const {
- return mirModule;
+ return &mirModule;
}
const MapleAllocator &GetIRMapAlloc() const {
@@ -199,20 +197,19 @@ class IRMap : public AnalysisResult {
}
private:
- SSATab *ssaTab;
- MIRModule *mirModule;
- Dominance *dom;
+ SSATab &ssaTab;
+ MIRModule &mirModule;
+ Dominance &dom;
MapleAllocator irMapAlloc;
MapleAllocator tempAlloc;
- int32 exprID; // for allocating exprid_ in MeExpr
+ int32 exprID = 0; // for allocating exprid_ in MeExpr
uint32 mapHashLength; // size of hashTable
MapleVector hashTable; // the value number hash table
MapleVector verst2MeExprTable; // map versionst to MeExpr.
MapleVector regMeExprTable; // record all the regmeexpr created by ssapre
- bool needAnotherPass; // set to true if CFG has changed
+ bool needAnotherPass = false; // set to true if CFG has changed
bool dumpStmtNum = false;
BB *curBB; // current maple_me::BB being visited
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_IRMAP_H
diff --git a/src/maple_me/include/me_alias_class.h b/src/maple_me/include/me_alias_class.h
index dc2268a8876869b26d0085dd8e08e2f821cb1ac7..9effc14348eea9428eeee827169cb952fcbc1a26 100644
--- a/src/maple_me/include/me_alias_class.h
+++ b/src/maple_me/include/me_alias_class.h
@@ -21,7 +21,7 @@
namespace maple {
class MeAliasClass : public AliasClass {
public:
- MeAliasClass(MemPool *memPool, MIRModule *mod, SSATab *ssaTab, MeFunction *func, bool lessAliasAtThrow,
+ MeAliasClass(MemPool &memPool, MIRModule &mod, SSATab &ssaTab, MeFunction &func, bool lessAliasAtThrow,
bool finalFieldHasAlias, bool ignoreIPA, bool debug, bool setCalleeHasSideEffect, KlassHierarchy *kh)
: AliasClass(memPool, mod, ssaTab, lessAliasAtThrow, finalFieldHasAlias, ignoreIPA, setCalleeHasSideEffect, kh),
func(func) {}
@@ -29,16 +29,16 @@ class MeAliasClass : public AliasClass {
virtual ~MeAliasClass() = default;
private:
- MeFunction *func;
- BB *GetBB(BBId id) {
- if (func->GetAllBBs().size() < id.idx) {
+ MeFunction &func;
+ BB *GetBB(BBId id) override {
+ if (func.GetAllBBs().size() < id.idx) {
return nullptr;
}
- return func->GetBBFromID(id);
+ return func.GetBBFromID(id);
}
- bool InConstructorLikeFunc() const {
- return func->GetMirFunc()->IsConstructor() || HasWriteToStaticFinal();
+ bool InConstructorLikeFunc() const override {
+ return func.GetMirFunc()->IsConstructor() || HasWriteToStaticFinal();
}
bool HasWriteToStaticFinal() const;
@@ -54,6 +54,5 @@ class MeDoAliasClass : public MeFuncPhase {
return "aliasclass";
}
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ME_ALIAS_CLASS_H
diff --git a/src/maple_me/include/me_bb_layout.h b/src/maple_me/include/me_bb_layout.h
index faeee76c3d9ee15b82af04c3ce99242cf159f7e7..8a0d0c9fc985587cf305c71ffe19749726d00321 100644
--- a/src/maple_me/include/me_bb_layout.h
+++ b/src/maple_me/include/me_bb_layout.h
@@ -20,34 +20,34 @@
namespace maple {
class BBLayout : public AnalysisResult {
private:
- MeFunction *func;
+ MeFunction &func;
MapleAllocator layoutAlloc;
MapleVector layoutBBs; // gives the determined layout order
- BBId curBBId; // to index into func->bb_vec_ to return the next BB
+ BBId curBBId; // to index into func.bb_vec_ to return the next BB
bool bbCreated; // new create bb will change mefunction::bb_vec_ and
// related analysis result
MapleVector laidOut; // indexed by bbid to tell if has been laid out
bool tryOutstanding; // true if a try laid out but not its endtry
public:
- BBLayout(MemPool *memPool, MeFunction *f)
- : AnalysisResult(memPool),
+ BBLayout(MemPool &memPool, MeFunction &f)
+ : AnalysisResult(&memPool),
func(f),
- layoutAlloc(memPool),
+ layoutAlloc(&memPool),
layoutBBs(layoutAlloc.Adapter()),
curBBId(0),
bbCreated(false),
- laidOut(func->GetAllBBs().size(), false, layoutAlloc.Adapter()),
+ laidOut(func.GetAllBBs().size(), false, layoutAlloc.Adapter()),
tryOutstanding(false) {
- laidOut[func->GetCommonEntryBB()->GetBBId().idx] = true;
- laidOut[func->GetCommonExitBB()->GetBBId().idx] = true;
+ laidOut[func.GetCommonEntryBB()->GetBBId().idx] = true;
+ laidOut[func.GetCommonExitBB()->GetBBId().idx] = true;
}
virtual ~BBLayout() = default;
BB *NextBB() {
// return the next BB following strictly program input order
curBBId.idx++;
- while (curBBId.idx < func->GetAllBBs().size()) {
- BB *nextBB = func->GetBBFromID(curBBId);
+ while (curBBId.idx < func.GetAllBBs().size()) {
+ BB *nextBB = func.GetBBFromID(curBBId);
if (nextBB != nullptr && !laidOut[nextBB->GetBBId().idx]) {
return nextBB;
}
@@ -56,16 +56,16 @@ class BBLayout : public AnalysisResult {
return nullptr;
}
- void OptimizeBranchTarget(BB *bb);
- bool BBEmptyAndFallthru(const BB *bb);
- bool BBContainsOnlyGoto(BB *bb);
- bool BBContainsOnlyCondGoto(BB *bb);
- bool HasSameBranchCond(BB *bb1, BB *bb2);
- bool BBCanBeMoved(BB *fromBB, const BB *toAfterBB);
- void AddBB(BB *bb);
- BB *GetFallThruBBSkippingEmpty(BB *bb);
- void ResolveUnconditionalFallThru(BB *bb, BB *nextBB);
- void ChangeToFallthruFromGoto(BB *bb);
+ void OptimizeBranchTarget(BB &bb);
+ bool BBEmptyAndFallthru(const BB &bb);
+ bool BBContainsOnlyGoto(BB &bb);
+ bool BBContainsOnlyCondGoto(BB &bb);
+ bool HasSameBranchCond(BB &bb1, BB &bb2);
+ bool BBCanBeMoved(BB &fromBB, const BB &toAfterBB);
+ void AddBB(BB &bb);
+ BB *GetFallThruBBSkippingEmpty(BB &bb);
+ void ResolveUnconditionalFallThru(BB &bb, BB &nextBB);
+ void ChangeToFallthruFromGoto(BB &bb);
const MapleVector &GetBBs() const {
return layoutBBs;
}
@@ -109,6 +109,5 @@ class MeDoBBLayout : public MeFuncPhase {
return "bblayout";
}
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ME_BB_LAYOUT_H
diff --git a/src/maple_me/include/me_cfg.h b/src/maple_me/include/me_cfg.h
index 5109baad142afa30e48d8fde41f0bb491669c8de..cc82bafad81ed854354d5ebf8f92bd1dbaa7ce09 100644
--- a/src/maple_me/include/me_cfg.h
+++ b/src/maple_me/include/me_cfg.h
@@ -18,29 +18,29 @@
#include "me_phase.h"
namespace maple {
-class MirCFG {
+class MeCFG {
public:
- explicit MirCFG(MeFunction *f) : func(f), hasDoWhile(false) {}
+ MeCFG(MeFunction &f) : func(f) {}
- ~MirCFG() {}
+ ~MeCFG() {}
void BuildMirCFG();
void FixMirCFG();
- void ConvertPhis2IdentityAssigns(BB *meBB);
+ void ConvertPhis2IdentityAssigns(BB &meBB);
void UnreachCodeAnalysis(bool updatePhi = false);
void WontExitAnalysis();
void Verify();
void VerifyLabels();
void Dump();
- void DumpToFile(const char *prefix, bool dumpInStrs = false);
+ void DumpToFile(const std::string &prefix, bool dumpInStrs = false);
void AddAuxilaryBB();
- bool FindExprUse(BaseNode *expr, StIdx stIdx);
- bool FindUse(StmtNode *stmt, StIdx stid);
- bool FindDef(StmtNode *stmt, StIdx stid);
- bool HasNoOccBetween(StmtNode *from, StmtNode *to, StIdx stIdx);
+ bool FindExprUse(BaseNode &expr, StIdx stIdx);
+ bool FindUse(StmtNode &stmt, StIdx stid);
+ bool FindDef(StmtNode &stmt, StIdx stid);
+ bool HasNoOccBetween(StmtNode &from, StmtNode &to, StIdx stIdx);
- MeFunction *GetFunc() {
+ MeFunction &GetFunc() {
return func;
}
@@ -53,9 +53,8 @@ class MirCFG {
}
private:
- MeFunction *func;
- bool hasDoWhile;
+ MeFunction &func;
+ bool hasDoWhile = false;
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ME_CFG_H
diff --git a/src/maple_me/include/me_dominance.h b/src/maple_me/include/me_dominance.h
index 2469bd19c4214975952782ce524602aa21f4cbc4..2b4f29d973e7cad6d757754a658aa302c0cd5f80 100644
--- a/src/maple_me/include/me_dominance.h
+++ b/src/maple_me/include/me_dominance.h
@@ -29,6 +29,5 @@ class MeDoDominance : public MeFuncPhase {
return "dominance";
}
};
-
} // namespace maple
-#endif // MAPLE_ME_INCLUDE_ME_DOMINANCE_H
+#endif // MAPLE_ME_INCLUDE_ME_DOMINANCE_H
\ No newline at end of file
diff --git a/src/maple_me/include/me_emit.h b/src/maple_me/include/me_emit.h
index f6a9c03fa1be69e9446cf04bc209a7356e1349dd..d7ff6c7034cf2e128d81e9f2ed42a8c061e9dee8 100644
--- a/src/maple_me/include/me_emit.h
+++ b/src/maple_me/include/me_emit.h
@@ -18,18 +18,16 @@
#include "me_phase.h"
/* emit ir to specified file */
-
namespace maple {
-class MeDoEmission : public MeFuncPhase {
+class MeDoEmit : public MeFuncPhase {
public:
- explicit MeDoEmission(MePhaseID id) : MeFuncPhase(id) {}
+ explicit MeDoEmit(MePhaseID id) : MeFuncPhase(id) {}
- virtual ~MeDoEmission() = default;
+ virtual ~MeDoEmit() = default;
AnalysisResult *Run(MeFunction *func, MeFuncResultMgr *m, ModuleResultMgr *mrm) override;
std::string PhaseName() const override {
return "emit";
}
};
-
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ME_EMIT_H
diff --git a/src/maple_me/include/me_function.h b/src/maple_me/include/me_function.h
index 6237137f7710f3067775a893a68e0afb697c0bcd..45b0d7e08cd91256ca95760d687f13af49ea1d7e 100644
--- a/src/maple_me/include/me_function.h
+++ b/src/maple_me/include/me_function.h
@@ -28,7 +28,7 @@
#include "me_ssa.h"
namespace maple {
-class MirCFG;
+class MeCFG;
class MeIRMap;
#if DEBUG
extern MIRModule *g_mirmodule;
@@ -398,11 +398,11 @@ class MeFunction : public FuncEmit {
return endTryBB2TryBB[endTry];
}
- MirCFG *GetTheCfg() {
+ MeCFG *GetTheCfg() {
return theCFG;
}
- void SetTheCfg(MirCFG *currTheCfg) {
+ void SetTheCfg(MeCFG *currTheCfg) {
theCFG = currTheCfg;
}
@@ -455,7 +455,7 @@ class MeFunction : public FuncEmit {
/* mempool */
MapleUnorderedMap