X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FAsmPrinter%2FAsmPrinter.cpp;h=28f5bc49dcabd2cf914680904b6fbafaddd852ec;hb=73e3fb6ba88bee77e46f15da4994299572cd15a0;hp=3c2f1d9ebcfc09ee30f583dcb7995b61e37588e4;hpb=cc714e214298cfbf11de65b46de31900d51422cf;p=oota-llvm.git diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 3c2f1d9ebcf..28f5bc49dca 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -179,7 +179,7 @@ bool AsmPrinter::doInitialization(Module &M) { OutStreamer->InitSections(false); - Mang = new Mangler(TM.getDataLayout()); + Mang = new Mangler(); // Emit the version-min deplyment target directive if needed. // @@ -548,10 +548,6 @@ void AsmPrinter::EmitFunctionHeader() { if (F->hasPrefixData()) EmitGlobalConstant(F->getPrefixData()); - // Emit the personality function. - if (F->hasPersonalityFn()) - EmitGlobalConstant(F->getPersonalityFn()); - // Emit the CurrentFnSym. This is a virtual function to allow targets to // do their wild and crazy things as required. EmitFunctionEntryLabel(); @@ -1795,40 +1791,30 @@ static int isRepeatedByteSequence(const ConstantDataSequential *V) { /// composed of a repeated sequence of identical bytes and return the /// byte value. If it is not a repeated sequence, return -1. static int isRepeatedByteSequence(const Value *V, TargetMachine &TM) { - if (const ConstantInt *CI = dyn_cast(V)) { - if (CI->getBitWidth() > 64) return -1; - - uint64_t Size = - TM.getDataLayout()->getTypeAllocSize(V->getType()); - uint64_t Value = CI->getZExtValue(); + uint64_t Size = TM.getDataLayout()->getTypeAllocSizeInBits(V->getType()); + assert(Size % 8 == 0); - // Make sure the constant is at least 8 bits long and has a power - // of 2 bit width. This guarantees the constant bit width is - // always a multiple of 8 bits, avoiding issues with padding out - // to Size and other such corner cases. - if (CI->getBitWidth() < 8 || !isPowerOf2_64(CI->getBitWidth())) return -1; + // Extend the element to take zero padding into account. + APInt Value = CI->getValue().zextOrSelf(Size); + if (!Value.isSplat(8)) + return -1; - uint8_t Byte = static_cast(Value); - - for (unsigned i = 1; i < Size; ++i) { - Value >>= 8; - if (static_cast(Value) != Byte) return -1; - } - return Byte; + return Value.zextOrTrunc(8).getZExtValue(); } if (const ConstantArray *CA = dyn_cast(V)) { // Make sure all array elements are sequences of the same repeated // byte. assert(CA->getNumOperands() != 0 && "Should be a CAZ"); - int Byte = isRepeatedByteSequence(CA->getOperand(0), TM); - if (Byte == -1) return -1; - - for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) { - int ThisByte = isRepeatedByteSequence(CA->getOperand(i), TM); - if (ThisByte == -1) return -1; - if (Byte != ThisByte) return -1; - } + Constant *Op0 = CA->getOperand(0); + int Byte = isRepeatedByteSequence(Op0, TM); + if (Byte == -1) + return -1; + + // All array elements must be equal. + for (unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) + if (CA->getOperand(i) != Op0) + return -1; return Byte; } @@ -2100,8 +2086,12 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME, MCValue MV; if (!(*ME)->evaluateAsRelocatable(MV, nullptr, nullptr) || MV.isAbsolute()) return; + const MCSymbolRefExpr *SymA = MV.getSymA(); + if (!SymA) + return; - const MCSymbol *GOTEquivSym = &MV.getSymA()->getSymbol(); + // Check that GOT equivalent symbol is cached. + const MCSymbol *GOTEquivSym = &SymA->getSymbol(); if (!AP.GlobalGOTEquivs.count(GOTEquivSym)) return; @@ -2109,8 +2099,11 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME, if (!BaseGV) return; + // Check for a valid base symbol const MCSymbol *BaseSym = AP.getSymbol(BaseGV); - if (BaseSym != &MV.getSymB()->getSymbol()) + const MCSymbolRefExpr *SymB = MV.getSymB(); + + if (!SymB || BaseSym != &SymB->getSymbol()) return; // Make sure to match: @@ -2306,11 +2299,10 @@ MCSymbol *AsmPrinter::getSymbolWithGlobalValueBase(const GlobalValue *GV, TM); } -/// GetExternalSymbolSymbol - Return the MCSymbol for the specified -/// ExternalSymbol. +/// Return the MCSymbol for the specified ExternalSymbol. MCSymbol *AsmPrinter::GetExternalSymbolSymbol(StringRef Sym) const { SmallString<60> NameStr; - Mang->getNameWithPrefix(NameStr, Sym); + Mangler::getNameWithPrefix(NameStr, Sym, *TM.getDataLayout()); return OutContext.getOrCreateSymbol(NameStr); }