diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/llvm/lib/Passes/StandardInstrumentations.cpp @@ -615,9 +615,15 @@ bool IRComparer::generateFunctionData(IRDataT &Data, const Function &F) { if (!F.isDeclaration() && isFunctionInPrintList(F.getName())) { FuncDataT FD(F.getEntryBlock().getName().str()); + int I = 0; for (const auto &B : F) { - FD.getOrder().emplace_back(B.getName()); - FD.getData().insert({B.getName(), B}); + std::string BBName = B.getName().str(); + if (BBName.empty()) { + BBName = formatv("{0}", I); + ++I; + } + FD.getOrder().emplace_back(BBName); + FD.getData().insert({BBName, B}); } Data.getOrder().emplace_back(F.getName()); Data.getData().insert({F.getName(), FD}); diff --git a/llvm/test/Other/ChangePrinters/print-changed-diff-empty-bb-name.ll b/llvm/test/Other/ChangePrinters/print-changed-diff-empty-bb-name.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Other/ChangePrinters/print-changed-diff-empty-bb-name.ll @@ -0,0 +1,18 @@ +; RUN: opt -passes=inline %s -disable-output --print-changed=diff 2>&1 | FileCheck %s + +; CHECK: IR Dump After InlinerPass + +define void @f(i1 %i) { + call void @g(i1 %i) + ret void +} + +define void @g(i1 %i) { + br i1 %i, label %1, label %2 + +1: + ret void + +2: + ret void +}