Skip to content

Commit a0d4125

Browse files
committed
[TSAR, Parallel, DVMH] Update debug output and assertions.
1 parent 077dc67 commit a0d4125

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

lib/Transform/Clang/DVMHSMAutoPar.cpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -978,9 +978,6 @@ bool ClangDVMHSMParallelization::initializeIPO(
978978
addToList(GetActual->getMemory(), mIPOToGetActual);
979979
}
980980
}
981-
//if (mIPOToActual.empty() && mIPOToGetActual.empty()) {
982-
// return true;
983-
//}
984981
auto &SocketInfo{getAnalysis<AnalysisSocketImmutableWrapper>()};
985982
auto &Socket{SocketInfo->getActive()->second};
986983
auto RM{Socket.getAnalysis<AnalysisClientServerMatcherWrapper>()};
@@ -1108,8 +1105,12 @@ bool ClangDVMHSMParallelization::initializeIPO(
11081105
dbgs() << "\n";
11091106
dbgs() << "[DVMH SM]: disable IPO for: ";
11101107
for (auto &&[F, Node] : functions())
1111-
if (auto I{mIPOMap.find(F)}; I == mIPOMap.end() || !I->get<bool>())
1112-
dbgs() << F->getName() << " ";
1108+
if (auto I{ mIPOMap.find(F) }; I == mIPOMap.end() || !I->get<bool>()) {
1109+
dbgs() << F->getName();
1110+
if (I != mIPOMap.end())
1111+
dbgs() << "(skip)";
1112+
dbgs() << " ";
1113+
}
11131114
dbgs() << "\n";
11141115
dbgs() << "[DVMH SM]: IPO, optimize accesses to ";
11151116
dbgs() << "actual: ";
@@ -1179,7 +1180,8 @@ bool ClangDVMHSMParallelization::optimizeGlobalIn(
11791180
SmallVectorImpl<VariableT> &ToOptimizeMemory) {
11801181
for (PragmaData *PI : FromList)
11811182
for (auto &Var : PI->getMemory()) {
1182-
assert(isa<DIGlobalVariable>(Var.get<MD>()->getVariable()) &&
1183+
assert(isa<DIGlobalVariable>(
1184+
cast<DIEstimateMemory>(Var.get<MD>())->getVariable()) &&
11831185
"IPO is now implemented for global variables only!");
11841186
auto CallerVar{findDIM(&**Var.get<MD>()->begin(), Var.get<AST>())};
11851187
assert(CallerVar.get<MD>() &&
@@ -1242,8 +1244,11 @@ bool ClangDVMHSMParallelization::optimizeGlobalIn(
12421244
Call->getCalledOperand()->stripPointerCasts())})
12431245
collectInCallee(Call, Callee, IsFinal);
12441246
};
1245-
assert(mReplacementFor.empty() && "Replacement stack must be empty!");
1247+
assert(!Level.is<Function *>() ||
1248+
mReplacementFor.empty() && "Replacement stack must be empty!");
12461249
mReplacementFor.emplace_back();
1250+
LLVM_DEBUG(dbgs() << "[DVMH SM]: add to replacement stack ("
1251+
<< mReplacementFor.size() << ")\n");
12471252
if (Level.is<Function *>()) {
12481253
LLVM_DEBUG(dbgs() << "[DVMH SM]: process function "
12491254
<< Level.get<Function *>()->getName() << "\n");
@@ -1256,12 +1261,16 @@ bool ClangDVMHSMParallelization::optimizeGlobalIn(
12561261
"metadata-level alias tree for the function"
12571262
<< F.getName() << "\n");
12581263
mReplacementFor.pop_back();
1264+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1265+
<< mReplacementFor.size() << ")\n");
12591266
mIPORoot.invalidate();
12601267
return false;
12611268
}
12621269
SmallVector<BasicBlock *, 8> OutermostBlocks;
12631270
if (!OptimizeChildren) {
12641271
mReplacementFor.emplace_back();
1272+
LLVM_DEBUG(dbgs() << "[DVMH SM]: add to replacement stack ("
1273+
<< mReplacementFor.size() << ")\n");
12651274
} else {
12661275
assert(IPOInfoItr != mIPOMap.end() && "Function must not be optimized!");
12671276
if (!OptimizeAll || IPOInfoItr->get<bool>()) {
@@ -1293,6 +1302,8 @@ bool ClangDVMHSMParallelization::optimizeGlobalIn(
12931302
collectForIPO(mIPOToGetActual, mToGetActual);
12941303
}
12951304
mReplacementFor.emplace_back();
1305+
LLVM_DEBUG(dbgs() << "[DVMH SM]: add to replacement stack ("
1306+
<< mReplacementFor.size() << ")\n");
12961307
auto &ServerDIAT{RF->value<DIEstimateMemoryPass *>()->getAliasTree()};
12971308
for (auto &DIM :
12981309
make_range(ServerDIAT.memory_begin(), ServerDIAT.memory_end()))
@@ -1359,7 +1370,11 @@ bool ClangDVMHSMParallelization::optimizeGlobalIn(
13591370
Call.second->getFunction(), true);
13601371
}
13611372
mReplacementFor.pop_back();
1373+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1374+
<< mReplacementFor.size() << ")\n");
13621375
mReplacementFor.pop_back();
1376+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1377+
<< mReplacementFor.size() << ")\n");
13631378
return false;
13641379
}
13651380
assert(IPOInfoItr != mIPOMap.end() && "Function must not be optimized!");
@@ -1688,7 +1703,11 @@ bool ClangDVMHSMParallelization::optimizeGlobalOut(
16881703
if (!needToOptimize(*Level.get<Function *>()).first) {
16891704
for (auto *PL: mReplacementFor.back().get<Sibling>())
16901705
PL->finalize();
1706+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1707+
<< mReplacementFor.size() << ")\n");
16911708
mReplacementFor.pop_back();
1709+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1710+
<< mReplacementFor.size() << ")\n");
16921711
mReplacementFor.pop_back();
16931712
return false;
16941713
}
@@ -1777,6 +1796,8 @@ bool ClangDVMHSMParallelization::optimizeGlobalOut(
17771796
for (auto *PL: mReplacementFor.back().get<Sibling>())
17781797
PL->finalize();
17791798
mReplacementFor.pop_back();
1799+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1800+
<< mReplacementFor.size() << ")\n");
17801801
return true;
17811802
}
17821803
for (auto *BB : Level.get<Loop *>()->blocks())
@@ -1841,6 +1862,8 @@ bool ClangDVMHSMParallelization::optimizeGlobalOut(
18411862
ToReplace->parent_insert(PL);
18421863
}
18431864
mReplacementFor.pop_back();
1865+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1866+
<< mReplacementFor.size() << ")\n");
18441867
if (!Level.is<Function *>()) {
18451868
for (auto *ToReplace : ConservativeReplacements)
18461869
mReplacementFor.back().get<Sibling>().push_back(
@@ -1860,6 +1883,8 @@ bool ClangDVMHSMParallelization::optimizeGlobalOut(
18601883
}
18611884
}
18621885
mReplacementFor.pop_back();
1886+
LLVM_DEBUG(dbgs() << "[DVMH SM]: extract from replacement stack ("
1887+
<< mReplacementFor.size() << ")\n");
18631888
}
18641889
return true;
18651890
}

0 commit comments

Comments
 (0)