Skip to content

Commit ba6b584

Browse files
committed
[Patmos] Fixed PML export.
Bitcode basic blocks without a name would get the name '', which would confuse Platin. Bitcode blocks without a name are now given their number as their name.
1 parent 929fc69 commit ba6b584

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

llvm/lib/Target/Patmos/PMLExport.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ template <> struct FlowGraphTrait<const BasicBlock> {
6161
return llvm::succ_end(BB);
6262
}
6363
static StringValue getName(const BasicBlock *BB) {
64-
return BB->getName().str();
64+
return BB->getNameOrAsOperand();
6565
}
6666
};
6767
template <> struct FlowGraphTrait<MachineBasicBlock> {
@@ -221,10 +221,10 @@ yaml::FlowFact<yaml::StringValue> *PMLBitcodeExport::createLoopFact(const BasicB
221221

222222
auto *FF = new yaml::FlowFact<yaml::StringValue>(yaml::level_bitcode);
223223

224-
FF->setLoopScope(Fn->getName().str(), BB->getName().str());
224+
FF->setLoopScope(Fn->getName().str(), BB->getNameOrAsOperand());
225225

226226
yaml::ProgramPoint *Block =
227-
yaml::ProgramPoint::CreateBlock(Fn->getName().str(), BB->getName().str());
227+
yaml::ProgramPoint::CreateBlock(Fn->getName().str(), BB->getNameOrAsOperand());
228228

229229
FF->addTermLHS(Block, 1LL);
230230
FF->RHS = RHS;
@@ -247,27 +247,24 @@ void PMLBitcodeExport::serialize(MachineFunction &MF)
247247
yaml::BitcodeFunction *F = new yaml::BitcodeFunction(Fn.getName().str());
248248
F->Level = yaml::level_bitcode;
249249
yaml::BitcodeBlock *B;
250-
for (Function::const_iterator BI = Fn.begin(), BE = Fn.end(); BI != BE;
250+
for (auto BI = Fn.begin(), BE = Fn.end(); BI != BE;
251251
++BI) {
252-
if (BI->getName().empty()) {
253-
llvm::errs() << "warning: unnamed bit-code BB in PML export\n";
254-
}
255-
B = F->addBlock(new yaml::BitcodeBlock(BI->getName().str()));
252+
B = F->addBlock(new yaml::BitcodeBlock(BI->getNameOrAsOperand()));
256253

257254
Loop *Loop = LI.getLoopFor(&*BI);
258255
while (Loop) {
259-
B->Loops.push_back(Loop->getHeader()->getName().str());
256+
B->Loops.push_back(Loop->getHeader()->getNameOrAsOperand());
260257
Loop = Loop->getParentLoop();
261258
}
262259

263260
/// B->MapsTo = (maybe C-source debug info?)
264-
for (const_pred_iterator PI = pred_begin(&*BI), PE = pred_end(&*BI);
261+
for (auto PI = pred_begin(&*BI), PE = pred_end(&*BI);
265262
PI != PE; ++PI) {
266-
B->Predecessors.push_back((*PI)->getName().str());
263+
B->Predecessors.push_back((*PI)->getNameOrAsOperand());
267264
}
268265
for (auto SI = succ_begin(&*BI), SE = succ_end(&*BI);
269266
SI != SE; ++SI) {
270-
B->Successors.push_back((*SI)->getName().str());
267+
B->Successors.push_back((*SI)->getNameOrAsOperand());
271268
}
272269

273270
unsigned Index = 0;
@@ -849,7 +846,7 @@ void addProgressNodes(yaml::RelationGraph *RG,
849846
}
850847
else {
851848
RN = RG->addNode(yaml::rnt_progress);
852-
RN->setSrcBlock(IQI->first->getName().str());
849+
RN->setSrcBlock(IQI->first->getNameOrAsOperand());
853850
RN->setDstBlock(MQI->first->getNumber());
854851
RMap.insert(std::make_pair(PNID, RN));
855852
RTodo.push_back(std::make_pair(PNID, RN));
@@ -935,7 +932,7 @@ void PMLRelationGraphExport::serialize(MachineFunction &MF)
935932
auto *SrcScope = new yaml::RelationScope<yaml::StringValue>(
936933
BF.getName().str(), yaml::level_bitcode);
937934
RG = new yaml::RelationGraph(SrcScope, DstScope);
938-
RG->getEntryNode()->setSrcBlock(BF.getEntryBlock().getName().str());
935+
RG->getEntryNode()->setSrcBlock(BF.getEntryBlock().getNameOrAsOperand());
939936
RG->getEntryNode()->setDstBlock(MF.front().getNumber());
940937
UnmatchedEvents.clear();
941938

@@ -974,7 +971,7 @@ void PMLRelationGraphExport::serialize(MachineFunction &MF)
974971
// MBB, resp.), which results in new src/dst nodes being created, and
975972
// two bitcode and machinecode-level maps from events to a list of
976973
// (bitcode/machine block, list of RG predecessor blocks) pairs
977-
expandProgressNode(RG, RN, yaml::rnt_src, [](auto *node, auto* block){node->setSrcBlock(block->getName().str());}, IBB, IEventMap, IEvents);
974+
expandProgressNode(RG, RN, yaml::rnt_src, [](auto *node, auto* block){node->setSrcBlock(block->getNameOrAsOperand());}, IBB, IEventMap, IEvents);
978975
expandProgressNode(RG, RN, yaml::rnt_dst, [](auto *node, auto* block){node->setDstBlock(block->getNumber());}, MBB, MEventMap, MEvents);
979976

980977
// For each event and corresponding bitcode list IList and machinecode

llvm/lib/Target/Patmos/PatmosExport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ namespace llvm {
367367
// FIXME
368368
// we don't add it immediately to PMF, as we only support
369369
// arguments in registers at this point
370-
std::string ArgName = ("%" + I->getName()).str();
370+
std::string ArgName = I->getNameOrAsOperand();
371371
yaml::Argument *Arg = new yaml::Argument(ArgName, FAIdx);
372372
bool allInRegs = true;
373373

0 commit comments

Comments
 (0)