Revert 42908 for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42960 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2007-10-14 05:57:21 +00:00
parent 296c176141
commit 347d39f1fd
13 changed files with 93 additions and 78 deletions

View File

@ -36,6 +36,13 @@ namespace llvm {
class AsmPrinter : public MachineFunctionPass { class AsmPrinter : public MachineFunctionPass {
static char ID; static char ID;
/// FunctionNumber - This provides a unique ID for each function emitted in
/// this translation unit. It is autoincremented by SetupMachineFunction,
/// and can be accessed with getFunctionNumber() and
/// IncrementFunctionNumber().
///
unsigned FunctionNumber;
protected: protected:
// Necessary for external weak linkage support // Necessary for external weak linkage support
std::set<const GlobalValue*> ExtWeakSymbols; std::set<const GlobalValue*> ExtWeakSymbols;
@ -153,6 +160,15 @@ namespace llvm {
/// is being processed from runOnMachineFunction. /// is being processed from runOnMachineFunction.
void SetupMachineFunction(MachineFunction &MF); void SetupMachineFunction(MachineFunction &MF);
/// getFunctionNumber - Return a unique ID for the current function.
///
unsigned getFunctionNumber() const { return FunctionNumber; }
/// IncrementFunctionNumber - Increase Function Number. AsmPrinters should
/// not normally call this, as the counter is automatically bumped by
/// SetupMachineFunction.
void IncrementFunctionNumber() { FunctionNumber++; }
/// EmitConstantPool - Print to the current output stream assembly /// EmitConstantPool - Print to the current output stream assembly
/// representations of the constants in the constant pool MCP. This is /// representations of the constants in the constant pool MCP. This is
/// used to print out constants which have been "spilled to memory" by /// used to print out constants which have been "spilled to memory" by

View File

@ -35,7 +35,7 @@ AsmVerbose("asm-verbose", cl::Hidden, cl::desc("Add comments to directives."));
char AsmPrinter::ID = 0; char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
const TargetAsmInfo *T) const TargetAsmInfo *T)
: MachineFunctionPass((intptr_t)&ID), O(o), TM(tm), TAI(T) : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T)
{} {}
std::string AsmPrinter::getSectionForFunction(const Function &F) const { std::string AsmPrinter::getSectionForFunction(const Function &F) const {
@ -169,6 +169,7 @@ std::string AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF) {
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
// What's my mangled name? // What's my mangled name?
CurrentFnName = Mang->getValueName(MF.getFunction()); CurrentFnName = Mang->getValueName(MF.getFunction());
IncrementFunctionNumber();
} }
/// EmitConstantPool - Print to the current output stream assembly /// EmitConstantPool - Print to the current output stream assembly
@ -218,9 +219,8 @@ void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section,
SwitchToDataSection(Section); SwitchToDataSection(Section);
EmitAlignment(Alignment); EmitAlignment(Alignment);
for (unsigned i = 0, e = CP.size(); i != e; ++i) { for (unsigned i = 0, e = CP.size(); i != e; ++i) {
O << TAI->getPrivateGlobalPrefix() << "CPI" << CP[i].second O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
<< '_' << CurrentFnName << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << " ";
<< ":\t\t\t\t\t" << TAI->getCommentString() << ' ';
WriteTypeSymbolic(O, CP[i].first.getType(), 0) << '\n'; WriteTypeSymbolic(O, CP[i].first.getType(), 0) << '\n';
if (CP[i].first.isMachineConstantPoolEntry()) if (CP[i].first.isMachineConstantPoolEntry())
EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal); EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
@ -293,10 +293,10 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
// the assembler and linker the extents of the jump table object. The // the assembler and linker the extents of the jump table object. The
// second label is actually referenced by the code. // second label is actually referenced by the code.
if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix()) if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix())
O << JTLabelPrefix << "JTI" << i << '_' << CurrentFnName << ":\n"; O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n";
O << TAI->getPrivateGlobalPrefix() << "JTI" << i O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName << ":\n"; << '_' << i << ":\n";
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) { for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
O << JTEntryDirective << ' '; O << JTEntryDirective << ' ';
@ -306,15 +306,15 @@ void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI,
// If we're emitting non-PIC code, then emit the entries as direct // If we're emitting non-PIC code, then emit the entries as direct
// references to the target basic blocks. // references to the target basic blocks.
if (!EmittedSets.empty()) { if (!EmittedSets.empty()) {
O << TAI->getPrivateGlobalPrefix() << i O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << "_set_" << JTBBs[ii]->getNumber() << '_' << CurrentFnName; << '_' << i << "_set_" << JTBBs[ii]->getNumber();
} else if (IsPic) { } else if (IsPic) {
printBasicBlockLabel(JTBBs[ii], false, false); printBasicBlockLabel(JTBBs[ii], false, false);
// If the arch uses custom Jump Table directives, don't calc relative to // If the arch uses custom Jump Table directives, don't calc relative to
// JT // JT
if (!HadJTEntryDirective) if (!HadJTEntryDirective)
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
<< i << '_' << CurrentFnName; << getFunctionNumber() << '_' << i;
} else { } else {
printBasicBlockLabel(JTBBs[ii], false, false); printBasicBlockLabel(JTBBs[ii], false, false);
} }
@ -1242,8 +1242,8 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB, void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printColon, bool printColon,
bool printComment) const { bool printComment) const {
O << TAI->getPrivateGlobalPrefix() << "BB" << MBB->getNumber() << '_' O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << "_"
<< CurrentFnName; << MBB->getNumber();
if (printColon) if (printColon)
O << ':'; O << ':';
if (printComment && MBB->getBasicBlock()) if (printComment && MBB->getBasicBlock())
@ -1259,10 +1259,10 @@ void AsmPrinter::printSetLabel(unsigned uid,
return; return;
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix() O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< uid << "_set_" << MBB->getNumber() << '_' << CurrentFnName << ','; << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false); printBasicBlockLabel(MBB, false, false);
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << uid O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName << '\n'; << '_' << uid << '\n';
} }
void AsmPrinter::printSetLabel(unsigned uid, unsigned uid2, void AsmPrinter::printSetLabel(unsigned uid, unsigned uid2,
@ -1271,11 +1271,11 @@ void AsmPrinter::printSetLabel(unsigned uid, unsigned uid2,
return; return;
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix() O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
<< uid << '_' << uid2 << getFunctionNumber() << '_' << uid << '_' << uid2
<< "_set_" << MBB->getNumber() << '_' << CurrentFnName << ','; << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false); printBasicBlockLabel(MBB, false, false);
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << uid O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << uid2 << '_' << CurrentFnName << '\n'; << '_' << uid << '_' << uid2 << '\n';
} }
/// printDataDirective - This method prints the asm directive for the /// printDataDirective - This method prints the asm directive for the

View File

@ -319,12 +319,12 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
break; break;
} }
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex() O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
<< '_' << CurrentFnName; << '_' << MO.getConstantPoolIndex();
break; break;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex() O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName; << '_' << MO.getJumpTableIndex();
break; break;
default: default:
O << "<unknown operand type>"; abort (); break; O << "<unknown operand type>"; abort (); break;
@ -652,8 +652,8 @@ void ARMAsmPrinter::printCPInstOperand(const MachineInstr *MI, int OpNo,
// data itself. // data itself.
if (!strcmp(Modifier, "label")) { if (!strcmp(Modifier, "label")) {
unsigned ID = MI->getOperand(OpNo).getImm(); unsigned ID = MI->getOperand(OpNo).getImm();
O << TAI->getPrivateGlobalPrefix() << "CPI" << ID O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
<< '_' << CurrentFnName << ":\n"; << '_' << ID << ":\n";
} else { } else {
assert(!strcmp(Modifier, "cpentry") && "Unknown modifier for CPE"); assert(!strcmp(Modifier, "cpentry") && "Unknown modifier for CPE");
unsigned CPI = MI->getOperand(OpNo).getConstantPoolIndex(); unsigned CPI = MI->getOperand(OpNo).getConstantPoolIndex();
@ -677,8 +677,8 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNo) {
const MachineOperand &MO1 = MI->getOperand(OpNo); const MachineOperand &MO1 = MI->getOperand(OpNo);
const MachineOperand &MO2 = MI->getOperand(OpNo+1); // Unique Id const MachineOperand &MO2 = MI->getOperand(OpNo+1); // Unique Id
unsigned JTI = MO1.getJumpTableIndex(); unsigned JTI = MO1.getJumpTableIndex();
O << TAI->getPrivateGlobalPrefix() << "JTI" << JTI O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << MO2.getImmedValue() << '_' << CurrentFnName << ":\n"; << '_' << JTI << '_' << MO2.getImmedValue() << ":\n";
const char *JTEntryDirective = TAI->getJumpTableDirective(); const char *JTEntryDirective = TAI->getJumpTableDirective();
if (!JTEntryDirective) if (!JTEntryDirective)
@ -697,16 +697,15 @@ void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNo) {
O << JTEntryDirective << ' '; O << JTEntryDirective << ' ';
if (UseSet) if (UseSet)
O << TAI->getPrivateGlobalPrefix() << JTI O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< '_' << MO2.getImmedValue() << '_' << JTI << '_' << MO2.getImmedValue()
<< "_set_" << MBB->getNumber() << "_set_" << MBB->getNumber();
<< CurrentFnName;
else if (TM.getRelocationModel() == Reloc::PIC_) { else if (TM.getRelocationModel() == Reloc::PIC_) {
printBasicBlockLabel(MBB, false, false); printBasicBlockLabel(MBB, false, false);
// If the arch uses custom Jump Table directives, don't calc relative to JT // If the arch uses custom Jump Table directives, don't calc relative to JT
if (!TAI->getJumpTableDirective()) if (!TAI->getJumpTableDirective())
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
<< JTI << '_' << MO2.getImmedValue() << '_' << CurrentFnName; << getFunctionNumber() << '_' << JTI << '_' << MO2.getImmedValue();
} else } else
printBasicBlockLabel(MBB, false, false); printBasicBlockLabel(MBB, false, false);
if (i != e-1) if (i != e-1)

View File

@ -104,8 +104,8 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
return; return;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex() O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
<< '_' << CurrentFnName; << MO.getConstantPoolIndex();
return; return;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
@ -121,8 +121,8 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
} }
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex() O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName; << '_' << MO.getJumpTableIndex();
return; return;
default: default:

View File

@ -179,8 +179,8 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
return; return;
case MachineOperand::MO_ConstantPoolIndex: { case MachineOperand::MO_ConstantPoolIndex: {
O << "@gprel(" << TAI->getPrivateGlobalPrefix() O << "@gprel(" << TAI->getPrivateGlobalPrefix()
<< "CPI" << MO.getConstantPoolIndex() << '_' << "CPI" << getFunctionNumber() << "_"
<< CurrentFnName << ")"; << MO.getConstantPoolIndex() << ")";
return; return;
} }

View File

@ -363,7 +363,7 @@ printOperand(const MachineInstr *MI, int opNum)
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" O << TAI->getPrivateGlobalPrefix() << "CPI"
<< MO.getConstantPoolIndex() << '_' << CurrentFnName; << getFunctionNumber() << "_" << MO.getConstantPoolIndex();
break; break;
default: default:

View File

@ -164,7 +164,7 @@ namespace {
O << "lo16("; O << "lo16(";
printOp(MI->getOperand(OpNo)); printOp(MI->getOperand(OpNo));
if (TM.getRelocationModel() == Reloc::PIC_) if (TM.getRelocationModel() == Reloc::PIC_)
O << "-\"L" "pb$" << CurrentFnName << "\")"; O << "-\"L" << getFunctionNumber() << "$pb\")";
else else
O << ')'; O << ')';
} }
@ -208,8 +208,8 @@ namespace {
O << (int)MI->getOperand(OpNo).getImmedValue()*4; O << (int)MI->getOperand(OpNo).getImmedValue()*4;
} }
void printPICLabel(const MachineInstr *MI, unsigned OpNo) { void printPICLabel(const MachineInstr *MI, unsigned OpNo) {
O << "\"L" "pb$" << CurrentFnName << "\"\n"; O << "\"L" << getFunctionNumber() << "$pb\"\n";
O << "\"L" "pb$" << CurrentFnName << "\":"; O << "\"L" << getFunctionNumber() << "$pb\":";
} }
void printSymbolHi(const MachineInstr *MI, unsigned OpNo) { void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
if (MI->getOperand(OpNo).isImmediate()) { if (MI->getOperand(OpNo).isImmediate()) {
@ -218,7 +218,7 @@ namespace {
if (Subtarget.isDarwin()) O << "ha16("; if (Subtarget.isDarwin()) O << "ha16(";
printOp(MI->getOperand(OpNo)); printOp(MI->getOperand(OpNo));
if (TM.getRelocationModel() == Reloc::PIC_) if (TM.getRelocationModel() == Reloc::PIC_)
O << "-\"L" "pb$" << CurrentFnName << "\""; O << "-\"L" << getFunctionNumber() << "$pb\"";
if (Subtarget.isDarwin()) if (Subtarget.isDarwin())
O << ')'; O << ')';
else else
@ -232,7 +232,7 @@ namespace {
if (Subtarget.isDarwin()) O << "lo16("; if (Subtarget.isDarwin()) O << "lo16(";
printOp(MI->getOperand(OpNo)); printOp(MI->getOperand(OpNo));
if (TM.getRelocationModel() == Reloc::PIC_) if (TM.getRelocationModel() == Reloc::PIC_)
O << "-\"L" "pb$" << CurrentFnName << "\""; O << "-\"L" << getFunctionNumber() << "$pb\"";
if (Subtarget.isDarwin()) if (Subtarget.isDarwin())
O << ')'; O << ')';
else else
@ -362,13 +362,13 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
printBasicBlockLabel(MO.getMachineBasicBlock()); printBasicBlockLabel(MO.getMachineBasicBlock());
return; return;
case MachineOperand::MO_JumpTableIndex: case MachineOperand::MO_JumpTableIndex:
O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex() O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName; << '_' << MO.getJumpTableIndex();
// FIXME: PIC relocation model // FIXME: PIC relocation model
return; return;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex() O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
<< '_' << CurrentFnName; << '_' << MO.getConstantPoolIndex();
return; return;
case MachineOperand::MO_ExternalSymbol: case MachineOperand::MO_ExternalSymbol:
// Computing the address of an external symbol, not calling it. // Computing the address of an external symbol, not calling it.

View File

@ -164,8 +164,8 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
O << MO.getSymbolName(); O << MO.getSymbolName();
break; break;
case MachineOperand::MO_ConstantPoolIndex: case MachineOperand::MO_ConstantPoolIndex:
O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex() O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
<< '_' << CurrentFnName; << MO.getConstantPoolIndex();
break; break;
default: default:
O << "<unknown operand type>"; abort (); break; O << "<unknown operand type>"; abort (); break;

View File

@ -31,14 +31,14 @@ using namespace llvm;
STATISTIC(EmittedInsts, "Number of machine instrs printed"); STATISTIC(EmittedInsts, "Number of machine instrs printed");
static std::string computePICLabel(const std::string &FnName, static std::string computePICLabel(unsigned FnNum,
const TargetAsmInfo *TAI, const TargetAsmInfo *TAI,
const X86Subtarget* Subtarget) { const X86Subtarget* Subtarget) {
std::string label; std::string label;
if (Subtarget->isTargetDarwin()) if (Subtarget->isTargetDarwin())
label = "\"L" "pb$" + FnName + "\""; label = "\"L" + utostr_32(FnNum) + "$pb\"";
else if (Subtarget->isTargetELF()) else if (Subtarget->isTargetELF())
label = ".Lllvm$piclabel$" + FnName; label = ".Lllvm$" + utostr_32(FnNum) + "$piclabel";
else else
assert(0 && "Don't know how to print PIC label!\n"); assert(0 && "Don't know how to print PIC label!\n");
@ -236,13 +236,13 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
case MachineOperand::MO_JumpTableIndex: { case MachineOperand::MO_JumpTableIndex: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
if (!isMemOp) O << '$'; if (!isMemOp) O << '$';
O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex() O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << "_"
<< '_' << CurrentFnName; << MO.getJumpTableIndex();
if (TM.getRelocationModel() == Reloc::PIC_) { if (TM.getRelocationModel() == Reloc::PIC_) {
if (Subtarget->isPICStyleStub()) if (Subtarget->isPICStyleStub())
O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< "\""; << "$pb\"";
else if (Subtarget->isPICStyleGOT()) else if (Subtarget->isPICStyleGOT())
O << "@GOTOFF"; O << "@GOTOFF";
} }
@ -254,13 +254,13 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
case MachineOperand::MO_ConstantPoolIndex: { case MachineOperand::MO_ConstantPoolIndex: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
if (!isMemOp) O << '$'; if (!isMemOp) O << '$';
O << TAI->getPrivateGlobalPrefix() << "CPI" << MO.getConstantPoolIndex() O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
<< '_' << CurrentFnName; << MO.getConstantPoolIndex();
if (TM.getRelocationModel() == Reloc::PIC_) { if (TM.getRelocationModel() == Reloc::PIC_) {
if (Subtarget->isPICStyleStub()) if (Subtarget->isPICStyleStub())
O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< "\""; << "$pb\"";
else if (Subtarget->isPICStyleGOT()) else if (Subtarget->isPICStyleGOT())
O << "@GOTOFF"; O << "@GOTOFF";
} }
@ -317,8 +317,8 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
} }
if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_) if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
O << "-\"" << TAI->getPrivateGlobalPrefix() << "pb$" << CurrentFnName O << "-\"" << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
<< "\""; << "$pb\"";
} else { } else {
if (GV->hasDLLImportLinkage()) { if (GV->hasDLLImportLinkage()) {
O << "__imp_"; O << "__imp_";
@ -418,7 +418,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
// popl %some_register // popl %some_register
// addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register // addl $_GLOBAL_ADDRESS_TABLE_ + [.-piclabel], %some_register
O << " + [.-" O << " + [.-"
<< computePICLabel(CurrentFnName, TAI, Subtarget) << "]"; << computePICLabel(getFunctionNumber(), TAI, Subtarget) << "]";
if (isCallOp) if (isCallOp)
O << "@PLT"; O << "@PLT";
@ -498,7 +498,7 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
} }
void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) { void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
std::string label = computePICLabel(CurrentFnName, TAI, Subtarget); std::string label = computePICLabel(getFunctionNumber(), TAI, Subtarget);
O << label << "\n" << label << ":"; O << label << "\n" << label << ":";
} }

View File

@ -140,15 +140,15 @@ void X86IntelAsmPrinter::printOp(const MachineOperand &MO,
case MachineOperand::MO_JumpTableIndex: { case MachineOperand::MO_JumpTableIndex: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
if (!isMemOp) O << "OFFSET "; if (!isMemOp) O << "OFFSET ";
O << TAI->getPrivateGlobalPrefix() << "JTI" << MO.getJumpTableIndex() O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
<< '_' << CurrentFnName; << "_" << MO.getJumpTableIndex();
return; return;
} }
case MachineOperand::MO_ConstantPoolIndex: { case MachineOperand::MO_ConstantPoolIndex: {
bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool isMemOp = Modifier && !strcmp(Modifier, "mem");
if (!isMemOp) O << "OFFSET "; if (!isMemOp) O << "OFFSET ";
O << "[" << TAI->getPrivateGlobalPrefix() << "CPI" O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
<< MO.getConstantPoolIndex() << '_' << CurrentFnName; << getFunctionNumber() << "_" << MO.getConstantPoolIndex();
int Offset = MO.getOffset(); int Offset = MO.getOffset();
if (Offset > 0) if (Offset > 0)
O << " + " << Offset; O << " + " << Offset;
@ -236,8 +236,8 @@ void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
} }
void X86IntelAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) { void X86IntelAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
O << "\"L" "pb$" << CurrentFnName << "\"\n"; O << "\"L" << getFunctionNumber() << "$pb\"\n";
O << "\"L" "pb$" << CurrentFnName << "\":"; O << "\"L" << getFunctionNumber() << "$pb\":";
} }
bool X86IntelAsmPrinter::printAsmMRegister(const MachineOperand &MO, bool X86IntelAsmPrinter::printAsmMRegister(const MachineOperand &MO,

View File

@ -1,5 +1,5 @@
; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 | %prcontext je 1 | \ ; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 | %prcontext je 1 | \
; RUN: grep BB | grep main ; RUN: grep BB1_1:
%str = internal constant [14 x sbyte] c"Hello world!\0A\00" ; <[14 x sbyte]*> [#uses=1] %str = internal constant [14 x sbyte] c"Hello world!\0A\00" ; <[14 x sbyte]*> [#uses=1]
%str = internal constant [13 x sbyte] c"Blah world!\0A\00" ; <[13 x sbyte]*> [#uses=1] %str = internal constant [13 x sbyte] c"Blah world!\0A\00" ; <[13 x sbyte]*> [#uses=1]

View File

@ -1,6 +1,6 @@
; PR1075 ; PR1075
; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | \ ; RUN: llvm-as < %s | llc -mtriple=x86_64-apple-darwin | \
; RUN: %prcontext {mulss LCPI3__foo} 1 | grep mulss | count 1 ; RUN: %prcontext {mulss LCPI1_3} 1 | grep mulss | count 1
define float @foo(float %x) { define float @foo(float %x) {
%tmp1 = mul float %x, 3.000000e+00 %tmp1 = mul float %x, 3.000000e+00

View File

@ -3,32 +3,32 @@
; Test that the load of the constant is folded into the operation. ; Test that the load of the constant is folded into the operation.
double %foo_add(double %P) { double %test_add(double %P) {
%tmp.1 = add double %P, 0x405EC00000000000 %tmp.1 = add double %P, 0x405EC00000000000
ret double %tmp.1 ret double %tmp.1
} }
double %foo_mul(double %P) { double %test_mul(double %P) {
%tmp.1 = mul double %P, 0x405EC00000000000 %tmp.1 = mul double %P, 0x405EC00000000000
ret double %tmp.1 ret double %tmp.1
} }
double %foo_sub(double %P) { double %test_sub(double %P) {
%tmp.1 = sub double %P, 0x405EC00000000000 %tmp.1 = sub double %P, 0x405EC00000000000
ret double %tmp.1 ret double %tmp.1
} }
double %foo_subr(double %P) { double %test_subr(double %P) {
%tmp.1 = sub double 0x405EC00000000000, %P %tmp.1 = sub double 0x405EC00000000000, %P
ret double %tmp.1 ret double %tmp.1
} }
double %foo_div(double %P) { double %test_div(double %P) {
%tmp.1 = div double %P, 0x405EC00000000000 %tmp.1 = div double %P, 0x405EC00000000000
ret double %tmp.1 ret double %tmp.1
} }
double %foo_divr(double %P) { double %test_divr(double %P) {
%tmp.1 = div double 0x405EC00000000000, %P %tmp.1 = div double 0x405EC00000000000, %P
ret double %tmp.1 ret double %tmp.1
} }