diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -4417,7 +4417,7 @@ void BasicBlock::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW, bool ShouldPreserveUseListOrder, bool IsForDebug) const { - SlotTracker SlotTable(this->getModule()); + SlotTracker SlotTable(this->getParent()); formatted_raw_ostream OS(ROS); AssemblyWriter W(OS, SlotTable, this->getModule(), AAW, IsForDebug, diff --git a/llvm/test/Other/bb-badref.ll b/llvm/test/Other/bb-badref.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Other/bb-badref.ll @@ -0,0 +1,14 @@ +; RUN: opt -passes=loop-instsimplify -print-after-all -disable-output -S < %s 2>&1 | FileCheck %s + +; loop-instsimplify dumps individual basic blocks as part of a loop, +; not a function. Verify that the non-entry basic block is labeled as +; "1", not "". + +; CHECK-NOT: + +define void @foo() { + br label %1 + +1: + br label %1 +}