Skip to content

Commit f11bb4d

Browse files
author
Andres Madrid Ucha
committed
GDA: merged two loops for opt on function list
We used to loop twice on all the functions of a module when we called GDA on opt.
1 parent c6623d7 commit f11bb4d

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

llvm/lib/CheerpUtils/GlobalDepsAnalyzer.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,15 @@ bool GlobalDepsAnalyzer::runOnModule( llvm::Module & module )
188188

189189
simplifyCalls(module);
190190

191-
if (!llcPass)
192-
{
193-
for (Function& F : module.getFunctionList())
191+
bool anyWasmFuncAddrTaken = false;
192+
// Replace calls like 'printf("Hello!")' with 'puts("Hello!")'.
193+
for (Function& F : module.getFunctionList()) {
194+
bool asmjs = F.getSection() == StringRef("asmjs");
195+
if (asmjs) {
196+
anyWasmFuncAddrTaken |= F.hasAddressTaken();
197+
}
198+
if (!llcPass)
194199
{
195-
//Those intrinsics may come back as result of other optimizations
196-
//And we may need the actual functions to lower the intrinsics
197200
const auto builtinID = BuiltinInstr::getMathBuiltin(F);
198201
const auto typedBuiltinID = TypedBuiltinInstr::getMathTypedBuiltin(F);
199202

@@ -204,20 +207,10 @@ bool GlobalDepsAnalyzer::runOnModule( llvm::Module & module )
204207
|| F.getName() == "memset"
205208
|| F.getName() == "memmove")
206209
{
207-
if (TypedBuiltinInstr::isAlwaysExactNatively(typedBuiltinID))
208-
continue;
209-
extendLifetime(&F);
210+
if (!TypedBuiltinInstr::isAlwaysExactNatively(typedBuiltinID))
211+
extendLifetime(&F);
210212
}
211213
}
212-
}
213-
214-
bool anyWasmFuncAddrTaken = false;
215-
// Replace calls like 'printf("Hello!")' with 'puts("Hello!")'.
216-
for (Function& F : module.getFunctionList()) {
217-
bool asmjs = F.getSection() == StringRef("asmjs");
218-
if (asmjs) {
219-
anyWasmFuncAddrTaken |= F.hasAddressTaken();
220-
}
221214
for (BasicBlock& bb : F)
222215
{
223216
bool advance = false; //Do not advance at the start

0 commit comments

Comments
 (0)