From 3eddf499b785903050e9f7e8b5bd696654503b73 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 29 Jul 2015 18:12:36 +0000 Subject: [PATCH] LowerBitSets: Add debugging output. Differential Revision: http://reviews.llvm.org/D11583 llvm-svn: 243546 --- llvm/include/llvm/Transforms/IPO/LowerBitSets.h | 3 +++ llvm/lib/Transforms/IPO/LowerBitSets.cpp | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/llvm/include/llvm/Transforms/IPO/LowerBitSets.h b/llvm/include/llvm/Transforms/IPO/LowerBitSets.h index 55d7d84..f678e86 100644 --- a/llvm/include/llvm/Transforms/IPO/LowerBitSets.h +++ b/llvm/include/llvm/Transforms/IPO/LowerBitSets.h @@ -28,6 +28,7 @@ namespace llvm { class DataLayout; class GlobalVariable; class Value; +class raw_ostream; struct BitSetInfo { // The indices of the set bits in the bitset. @@ -57,6 +58,8 @@ struct BitSetInfo { bool containsValue(const DataLayout &DL, const DenseMap &GlobalLayout, Value *V, uint64_t COffset = 0) const; + + void print(raw_ostream &OS) const; }; struct BitSetBuilder { diff --git a/llvm/lib/Transforms/IPO/LowerBitSets.cpp b/llvm/lib/Transforms/IPO/LowerBitSets.cpp index c6795c6..bf386a6 100644 --- a/llvm/lib/Transforms/IPO/LowerBitSets.cpp +++ b/llvm/lib/Transforms/IPO/LowerBitSets.cpp @@ -26,6 +26,8 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" #include "llvm/Pass.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" using namespace llvm; @@ -90,6 +92,22 @@ bool BitSetInfo::containsValue( return false; } +void BitSetInfo::print(raw_ostream &OS) const { + OS << "offset " << ByteOffset << " size " << BitSize << " align " + << (1 << AlignLog2); + + if (isAllOnes()) { + OS << " all-ones\n"; + return; + } + + OS << " { "; + for (uint64_t B : Bits) + OS << B << ' '; + OS << "}\n"; + return; +} + BitSetInfo BitSetBuilder::build() { if (Min > Max) Min = 0; @@ -532,6 +550,10 @@ void LowerBitSets::buildBitSetsFromGlobals( for (MDString *BS : BitSets) { // Build the bitset. BitSetInfo BSI = buildBitSet(BS, GlobalLayout); + DEBUG({ + dbgs() << BS->getString() << ": "; + BSI.print(dbgs()); + }); ByteArrayInfo *BAI = 0; -- 2.7.4