diff options
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 10 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 10 | ||||
-rw-r--r-- | lib/Target/SparcV9/InternalGlobalMapper.cpp | 2 | ||||
-rw-r--r-- | lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 2 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 15 |
5 files changed, 15 insertions, 24 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 139320f640..c1cd657cf2 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -620,8 +620,8 @@ void CWriter::printConstant(Constant *CPV) { printType(Out, CPV->getType()); Out << ")/*NULL*/0)"; break; - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CPV)) { - writeOperand(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast<GlobalValue>(CPV)) { + writeOperand(GV); break; } // FALL THROUGH @@ -641,7 +641,8 @@ void CWriter::writeOperandInternal(Value *Operand) { return; } - if (Constant *CPV = dyn_cast<Constant>(Operand)) { + Constant* CPV = dyn_cast<Constant>(Operand); + if (CPV && !isa<GlobalValue>(CPV)) { printConstant(CPV); } else { Out << Mang->getValueName(Operand); @@ -1412,9 +1413,6 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, // If accessing a global value with no indexing, avoid *(&GV) syndrome if (GlobalValue *V = dyn_cast<GlobalValue>(Ptr)) { HasImplicitAddress = true; - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr)) { - HasImplicitAddress = true; - Ptr = CPR->getValue(); // Get to the global... } else if (isDirectAlloca(Ptr)) { HasImplicitAddress = true; } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 139320f640..c1cd657cf2 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -620,8 +620,8 @@ void CWriter::printConstant(Constant *CPV) { printType(Out, CPV->getType()); Out << ")/*NULL*/0)"; break; - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CPV)) { - writeOperand(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast<GlobalValue>(CPV)) { + writeOperand(GV); break; } // FALL THROUGH @@ -641,7 +641,8 @@ void CWriter::writeOperandInternal(Value *Operand) { return; } - if (Constant *CPV = dyn_cast<Constant>(Operand)) { + Constant* CPV = dyn_cast<Constant>(Operand); + if (CPV && !isa<GlobalValue>(CPV)) { printConstant(CPV); } else { Out << Mang->getValueName(Operand); @@ -1412,9 +1413,6 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, // If accessing a global value with no indexing, avoid *(&GV) syndrome if (GlobalValue *V = dyn_cast<GlobalValue>(Ptr)) { HasImplicitAddress = true; - } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Ptr)) { - HasImplicitAddress = true; - Ptr = CPR->getValue(); // Get to the global... } else if (isDirectAlloca(Ptr)) { HasImplicitAddress = true; } diff --git a/lib/Target/SparcV9/InternalGlobalMapper.cpp b/lib/Target/SparcV9/InternalGlobalMapper.cpp index 7d4a40a13b..0cd2faa7c3 100644 --- a/lib/Target/SparcV9/InternalGlobalMapper.cpp +++ b/lib/Target/SparcV9/InternalGlobalMapper.cpp @@ -42,7 +42,7 @@ static void maybeAddInternalValueToVector (GVVectorTy &Vector, GlobalValue &GV){ // add a null. if (GV.hasInternalLinkage () && GV.hasName ()) Vector.push_back (ConstantExpr::getCast - (ConstantPointerRef::get (&GV), PointerType::get (Type::SByteTy))); + (&GV, PointerType::get (Type::SByteTy))); else Vector.push_back (ConstantPointerNull::get (PointerType::get (Type::SByteTy))); diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index a153871d80..6aebcb5f84 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -1289,7 +1289,7 @@ void PhyRegAlloc::finishSavingState (Module &M) { // Have: { uint, [Size x { uint, int, uint, int }] } * // Cast it to: { uint, [0 x { uint, int, uint, int }] } * - Constant *CE = ConstantExpr::getCast (ConstantPointerRef::get (GV), PT); + Constant *CE = ConstantExpr::getCast (GV, PT); allstate.push_back (CE); } } diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index aa18345255..addcbdcc0c 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -317,11 +317,8 @@ void AsmPrinter::printSingleConstantValue(const Constant* CV) { toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t"; - if (const ConstantPointerRef* CPR = dyn_cast<ConstantPointerRef>(CV)) { - // This is a constant address for a global variable or method. - // Use the name of the variable or method as the address value. - assert(isa<GlobalValue>(CPR->getValue()) && "Unexpected non-global"); - toAsm << getID(CPR->getValue()) << "\n"; + if (const GlobalValue* GV = dyn_cast<GlobalValue>(CV)) { + toAsm << getID(GV) << "\n"; } else if (isa<ConstantPointerNull>(CV)) { // Null pointer value toAsm << "0\n"; @@ -480,7 +477,9 @@ std::string AsmPrinter::valToExprString(const Value* V, const TargetMachine& target) { std::string S; bool failed = false; - if (const Constant* CV = dyn_cast<Constant>(V)) { // symbolic or known + if (const GlobalValue* GV = dyn_cast<GlobalValue>(V)) { + S += getID(GV); + } else if (const Constant* CV = dyn_cast<Constant>(V)) { // symbolic or known if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) S += std::string(CB == ConstantBool::True ? "1" : "0"); else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) @@ -491,14 +490,10 @@ std::string AsmPrinter::valToExprString(const Value* V, S += ftostr(CFP->getValue()); else if (isa<ConstantPointerNull>(CV)) S += "0"; - else if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CV)) - S += valToExprString(CPR->getValue(), target); else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) S += ConstantExprToString(CE, target); else failed = true; - } else if (const GlobalValue* GV = dyn_cast<GlobalValue>(V)) { - S += getID(GV); } else failed = true; |