diff options
Diffstat (limited to 'lib/Target/ARM/ARMConstantPoolValue.cpp')
| -rw-r--r-- | lib/Target/ARM/ARMConstantPoolValue.cpp | 26 | 
1 files changed, 17 insertions, 9 deletions
| diff --git a/lib/Target/ARM/ARMConstantPoolValue.cpp b/lib/Target/ARM/ARMConstantPoolValue.cpp index f13ccc638448..165a1d849ad5 100644 --- a/lib/Target/ARM/ARMConstantPoolValue.cpp +++ b/lib/Target/ARM/ARMConstantPoolValue.cpp @@ -24,7 +24,7 @@ using namespace llvm;  ARMConstantPoolValue::ARMConstantPoolValue(const Constant *cval, unsigned id,                                             ARMCP::ARMCPKind K,                                             unsigned char PCAdj, -                                           const char *Modif, +                                           ARMCP::ARMCPModifier Modif,                                             bool AddCA)    : MachineConstantPoolValue((const Type*)cval->getType()),      CVal(cval), S(NULL), LabelId(id), Kind(K), PCAdjust(PCAdj), @@ -33,17 +33,17 @@ ARMConstantPoolValue::ARMConstantPoolValue(const Constant *cval, unsigned id,  ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,                                             const char *s, unsigned id,                                             unsigned char PCAdj, -                                           const char *Modif, +                                           ARMCP::ARMCPModifier Modif,                                             bool AddCA)    : MachineConstantPoolValue((const Type*)Type::getInt32Ty(C)),      CVal(NULL), S(strdup(s)), LabelId(id), Kind(ARMCP::CPExtSymbol),      PCAdjust(PCAdj), Modifier(Modif), AddCurrentAddress(AddCA) {}  ARMConstantPoolValue::ARMConstantPoolValue(const GlobalValue *gv, -                                           const char *Modif) +                                           ARMCP::ARMCPModifier Modif)    : MachineConstantPoolValue((const Type*)Type::getInt32Ty(gv->getContext())),      CVal(gv), S(NULL), LabelId(0), Kind(ARMCP::CPValue), PCAdjust(0), -    Modifier(Modif) {} +    Modifier(Modif), AddCurrentAddress(false) {}  const GlobalValue *ARMConstantPoolValue::getGV() const {    return dyn_cast_or_null<GlobalValue>(CVal); @@ -53,6 +53,14 @@ const BlockAddress *ARMConstantPoolValue::getBlockAddress() const {    return dyn_cast_or_null<BlockAddress>(CVal);  } +static bool CPV_streq(const char *S1, const char *S2) { +  if (S1 == S2) +    return true; +  if (S1 && S2 && strcmp(S1, S2) == 0) +    return true; +  return false; +} +  int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,                                                      unsigned Alignment) {    unsigned AlignMask = Alignment - 1; @@ -65,8 +73,8 @@ int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,        if (CPV->CVal == CVal &&            CPV->LabelId == LabelId &&            CPV->PCAdjust == PCAdjust && -          (CPV->S == S || strcmp(CPV->S, S) == 0) && -          (CPV->Modifier == Modifier || strcmp(CPV->Modifier, Modifier) == 0)) +          CPV_streq(CPV->S, S) && +          CPV->Modifier == Modifier)          return i;      }    } @@ -91,8 +99,8 @@ ARMConstantPoolValue::hasSameValue(ARMConstantPoolValue *ACPV) {    if (ACPV->Kind == Kind &&        ACPV->CVal == CVal &&        ACPV->PCAdjust == PCAdjust && -      (ACPV->S == S || strcmp(ACPV->S, S) == 0) && -      (ACPV->Modifier == Modifier || strcmp(ACPV->Modifier, Modifier) == 0)) { +      CPV_streq(ACPV->S, S) && +      ACPV->Modifier == Modifier) {      if (ACPV->LabelId == LabelId)        return true;      // Two PC relative constpool entries containing the same GV address or @@ -113,7 +121,7 @@ void ARMConstantPoolValue::print(raw_ostream &O) const {      O << CVal->getName();    else      O << S; -  if (Modifier) O << "(" << Modifier << ")"; +  if (Modifier) O << "(" << getModifierText() << ")";    if (PCAdjust != 0) {      O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;      if (AddCurrentAddress) O << "-."; | 
