[llvm] 41d5319 - [BasicBlock] Added AnnotationWriter functionality to BasicBlock class
Kirill Naumov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 18 12:50:15 PDT 2020
Author: Kirill Naumov
Date: 2020-06-18T19:49:58Z
New Revision: 41d53194fb9d5aba3e4861233b1af9cb62cc999a
URL: https://github.com/llvm/llvm-project/commit/41d53194fb9d5aba3e4861233b1af9cb62cc999a
DIFF: https://github.com/llvm/llvm-project/commit/41d53194fb9d5aba3e4861233b1af9cb62cc999a.diff
LOG: [BasicBlock] Added AnnotationWriter functionality to BasicBlock class
This functionality is very similar to Function compatibility with
AnnotationWriter. This change allows us to use AnnotationWriter with
BasicBlock through BB.print() method.
Reviewed-By: apilipenko
Differntial Revision: https://reviews.llvm.org/D81321
Added:
Modified:
llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/AsmWriter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h
index 8eeafdbaa794..24d568a728c6 100644
--- a/llvm/include/llvm/IR/BasicBlock.h
+++ b/llvm/include/llvm/IR/BasicBlock.h
@@ -31,6 +31,7 @@
namespace llvm {
+class AssemblyAnnotationWriter;
class CallInst;
class Function;
class LandingPadInst;
@@ -276,6 +277,12 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
static_cast<const BasicBlock *>(this)->getUniqueSuccessor());
}
+ /// Print the basic block to an output stream with an optional
+ /// AssemblyAnnotationWriter.
+ void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW = nullptr,
+ bool ShouldPreserveUseListOrder = false,
+ bool IsForDebug = false) const;
+
//===--------------------------------------------------------------------===//
/// Instruction iterator methods
///
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index efaeadbe7c3a..53bfae23441b 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4360,6 +4360,17 @@ void Function::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
W.printFunction(this);
}
+void BasicBlock::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
+ bool ShouldPreserveUseListOrder,
+ bool IsForDebug) const {
+ SlotTracker SlotTable(this->getModule());
+ formatted_raw_ostream OS(ROS);
+ AssemblyWriter W(OS, SlotTable, this->getModule(), AAW,
+ IsForDebug,
+ ShouldPreserveUseListOrder);
+ W.printBasicBlock(this);
+}
+
void Module::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
bool ShouldPreserveUseListOrder, bool IsForDebug) const {
SlotTracker SlotTable(this);
More information about the llvm-commits
mailing list