mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-18 06:38:41 +00:00
printName is almost always true. In the cases that mattered where it was false,
it was effectively set to true by this: - if ((PrintName || isa<GlobalValue>(V)) && V->hasName()) + if (V->hasName()) Delete printname entirely. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32265 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3749c9cae4
commit
2fcfdb79d0
@ -152,7 +152,6 @@ static RegisterPass<PrintFunctionPass>
|
|||||||
Y("print","Print function to stderr");
|
Y("print","Print function to stderr");
|
||||||
|
|
||||||
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
|
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
|
||||||
bool PrintName,
|
|
||||||
std::map<const Type *, std::string> &TypeTable,
|
std::map<const Type *, std::string> &TypeTable,
|
||||||
SlotMachine *Machine);
|
SlotMachine *Machine);
|
||||||
|
|
||||||
@ -427,7 +426,6 @@ static const char * getPredicateText(unsigned predicate) {
|
|||||||
|
|
||||||
/// @brief Internal constant writer.
|
/// @brief Internal constant writer.
|
||||||
static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
||||||
bool PrintName,
|
|
||||||
std::map<const Type *, std::string> &TypeTable,
|
std::map<const Type *, std::string> &TypeTable,
|
||||||
SlotMachine *Machine) {
|
SlotMachine *Machine) {
|
||||||
const int IndentSize = 4;
|
const int IndentSize = 4;
|
||||||
@ -484,12 +482,11 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
|||||||
Out << ' ';
|
Out << ' ';
|
||||||
printTypeInt(Out, ETy, TypeTable);
|
printTypeInt(Out, ETy, TypeTable);
|
||||||
WriteAsOperandInternal(Out, CA->getOperand(0),
|
WriteAsOperandInternal(Out, CA->getOperand(0),
|
||||||
PrintName, TypeTable, Machine);
|
TypeTable, Machine);
|
||||||
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
printTypeInt(Out, ETy, TypeTable);
|
printTypeInt(Out, ETy, TypeTable);
|
||||||
WriteAsOperandInternal(Out, CA->getOperand(i), PrintName,
|
WriteAsOperandInternal(Out, CA->getOperand(i), TypeTable, Machine);
|
||||||
TypeTable, Machine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Out << " ]";
|
Out << " ]";
|
||||||
@ -506,16 +503,14 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
|||||||
}
|
}
|
||||||
printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable);
|
printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable);
|
||||||
|
|
||||||
WriteAsOperandInternal(Out, CS->getOperand(0),
|
WriteAsOperandInternal(Out, CS->getOperand(0), TypeTable, Machine);
|
||||||
PrintName, TypeTable, Machine);
|
|
||||||
|
|
||||||
for (unsigned i = 1; i < N; i++) {
|
for (unsigned i = 1; i < N; i++) {
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
if (N > 2) Out << Indent;
|
if (N > 2) Out << Indent;
|
||||||
printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable);
|
printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable);
|
||||||
|
|
||||||
WriteAsOperandInternal(Out, CS->getOperand(i),
|
WriteAsOperandInternal(Out, CS->getOperand(i), TypeTable, Machine);
|
||||||
PrintName, TypeTable, Machine);
|
|
||||||
}
|
}
|
||||||
if (N > 2) Indent.resize(Indent.size() - IndentSize);
|
if (N > 2) Indent.resize(Indent.size() - IndentSize);
|
||||||
}
|
}
|
||||||
@ -528,13 +523,11 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
|||||||
Out << '<';
|
Out << '<';
|
||||||
Out << ' ';
|
Out << ' ';
|
||||||
printTypeInt(Out, ETy, TypeTable);
|
printTypeInt(Out, ETy, TypeTable);
|
||||||
WriteAsOperandInternal(Out, CP->getOperand(0),
|
WriteAsOperandInternal(Out, CP->getOperand(0), TypeTable, Machine);
|
||||||
PrintName, TypeTable, Machine);
|
|
||||||
for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 1, e = CP->getNumOperands(); i != e; ++i) {
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
printTypeInt(Out, ETy, TypeTable);
|
printTypeInt(Out, ETy, TypeTable);
|
||||||
WriteAsOperandInternal(Out, CP->getOperand(i), PrintName,
|
WriteAsOperandInternal(Out, CP->getOperand(i), TypeTable, Machine);
|
||||||
TypeTable, Machine);
|
|
||||||
}
|
}
|
||||||
Out << " >";
|
Out << " >";
|
||||||
} else if (isa<ConstantPointerNull>(CV)) {
|
} else if (isa<ConstantPointerNull>(CV)) {
|
||||||
@ -551,7 +544,7 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
|||||||
|
|
||||||
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
|
for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) {
|
||||||
printTypeInt(Out, (*OI)->getType(), TypeTable);
|
printTypeInt(Out, (*OI)->getType(), TypeTable);
|
||||||
WriteAsOperandInternal(Out, *OI, PrintName, TypeTable, Machine);
|
WriteAsOperandInternal(Out, *OI, TypeTable, Machine);
|
||||||
if (OI+1 != CE->op_end())
|
if (OI+1 != CE->op_end())
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
}
|
}
|
||||||
@ -574,16 +567,15 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
|
|||||||
/// the whole instruction that generated it.
|
/// the whole instruction that generated it.
|
||||||
///
|
///
|
||||||
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
|
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
|
||||||
bool PrintName,
|
|
||||||
std::map<const Type*, std::string> &TypeTable,
|
std::map<const Type*, std::string> &TypeTable,
|
||||||
SlotMachine *Machine) {
|
SlotMachine *Machine) {
|
||||||
Out << ' ';
|
Out << ' ';
|
||||||
if ((PrintName || isa<GlobalValue>(V)) && V->hasName())
|
if (V->hasName())
|
||||||
Out << getLLVMName(V->getName());
|
Out << getLLVMName(V->getName());
|
||||||
else {
|
else {
|
||||||
const Constant *CV = dyn_cast<Constant>(V);
|
const Constant *CV = dyn_cast<Constant>(V);
|
||||||
if (CV && !isa<GlobalValue>(CV)) {
|
if (CV && !isa<GlobalValue>(CV)) {
|
||||||
WriteConstantInt(Out, CV, PrintName, TypeTable, Machine);
|
WriteConstantInt(Out, CV, TypeTable, Machine);
|
||||||
} else if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
|
} else if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
|
||||||
Out << "asm ";
|
Out << "asm ";
|
||||||
if (IA->hasSideEffects())
|
if (IA->hasSideEffects())
|
||||||
@ -628,7 +620,7 @@ std::ostream &llvm::WriteAsOperand(std::ostream &Out, const Value *V,
|
|||||||
if (PrintType)
|
if (PrintType)
|
||||||
printTypeInt(Out, V->getType(), TypeNames);
|
printTypeInt(Out, V->getType(), TypeNames);
|
||||||
|
|
||||||
WriteAsOperandInternal(Out, V, true, TypeNames, 0);
|
WriteAsOperandInternal(Out, V, TypeNames, 0);
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +652,7 @@ public:
|
|||||||
inline void write(const Constant *CPV) { printConstant(CPV); }
|
inline void write(const Constant *CPV) { printConstant(CPV); }
|
||||||
inline void write(const Type *Ty) { printType(Ty); }
|
inline void write(const Type *Ty) { printType(Ty); }
|
||||||
|
|
||||||
void writeOperand(const Value *Op, bool PrintType, bool PrintName = true);
|
void writeOperand(const Value *Op, bool PrintType);
|
||||||
|
|
||||||
const Module* getModule() { return TheModule; }
|
const Module* getModule() { return TheModule; }
|
||||||
|
|
||||||
@ -738,13 +730,12 @@ std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType,
|
void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
|
||||||
bool PrintName) {
|
if (Operand == 0) {
|
||||||
if (Operand != 0) {
|
|
||||||
if (PrintType) { Out << ' '; printType(Operand->getType()); }
|
|
||||||
WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
|
|
||||||
} else {
|
|
||||||
Out << "<null operand!>";
|
Out << "<null operand!>";
|
||||||
|
} else {
|
||||||
|
if (PrintType) { Out << ' '; printType(Operand->getType()); }
|
||||||
|
WriteAsOperandInternal(Out, Operand, TypeNames, &Machine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,7 +841,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
|
|||||||
if (GV->hasInitializer()) {
|
if (GV->hasInitializer()) {
|
||||||
Constant* C = cast<Constant>(GV->getInitializer());
|
Constant* C = cast<Constant>(GV->getInitializer());
|
||||||
assert(C && "GlobalVar initializer isn't constant?");
|
assert(C && "GlobalVar initializer isn't constant?");
|
||||||
writeOperand(GV->getInitializer(), false, isa<GlobalValue>(C));
|
writeOperand(GV->getInitializer(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GV->hasSection())
|
if (GV->hasSection())
|
||||||
@ -904,8 +895,8 @@ void AssemblyWriter::printConstant(const Constant *CPV) {
|
|||||||
// Print out name...
|
// Print out name...
|
||||||
Out << "\t" << getLLVMName(CPV->getName()) << " =";
|
Out << "\t" << getLLVMName(CPV->getName()) << " =";
|
||||||
|
|
||||||
// Write the value out now...
|
// Write the value out now.
|
||||||
writeOperand(CPV, true, false);
|
writeOperand(CPV, true);
|
||||||
|
|
||||||
printInfoComment(*CPV);
|
printInfoComment(*CPV);
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
@ -1037,10 +1028,10 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
|
|||||||
Out << " No predecessors!";
|
Out << " No predecessors!";
|
||||||
} else {
|
} else {
|
||||||
Out << " preds =";
|
Out << " preds =";
|
||||||
writeOperand(*PI, false, true);
|
writeOperand(*PI, false);
|
||||||
for (++PI; PI != PE; ++PI) {
|
for (++PI; PI != PE; ++PI) {
|
||||||
Out << ',';
|
Out << ',';
|
||||||
writeOperand(*PI, false, true);
|
writeOperand(*PI, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1299,7 +1290,7 @@ void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
WriteAsOperand(o, this, true, true, 0);
|
WriteAsOperand(o, this, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
@ -1323,7 +1314,7 @@ void Constant::print(std::ostream &o) const {
|
|||||||
o << ' ' << getType()->getDescription() << ' ';
|
o << ' ' << getType()->getDescription() << ' ';
|
||||||
|
|
||||||
std::map<const Type *, std::string> TypeTable;
|
std::map<const Type *, std::string> TypeTable;
|
||||||
WriteConstantInt(o, this, false, TypeTable, 0);
|
WriteConstantInt(o, this, TypeTable, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Type::print(std::ostream &o) const {
|
void Type::print(std::ostream &o) const {
|
||||||
@ -1334,8 +1325,7 @@ void Type::print(std::ostream &o) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Argument::print(std::ostream &o) const {
|
void Argument::print(std::ostream &o) const {
|
||||||
WriteAsOperand(o, this, true, true,
|
WriteAsOperand(o, this, true, getParent() ? getParent()->getParent() : 0);
|
||||||
getParent() ? getParent()->getParent() : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value::dump - allow easy printing of Values from the debugger.
|
// Value::dump - allow easy printing of Values from the debugger.
|
||||||
@ -1376,7 +1366,7 @@ CachedWriter &CachedWriter::operator<<(const Value &V) {
|
|||||||
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(&V))
|
else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(&V))
|
||||||
AW->write(GV);
|
AW->write(GV);
|
||||||
else
|
else
|
||||||
AW->writeOperand(&V, true, true);
|
AW->writeOperand(&V, true);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user