From aba9bcb9b60edbad3646b2f3088c120d06549cc7 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 14 Mar 2010 07:27:07 +0000 Subject: switch GC_LABEL to use an MCSymbol operand instead of a label ID operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98474 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/GCMetadata.h | 12 ++++----- include/llvm/CodeGen/GCMetadataPrinter.h | 1 + lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 4 +-- lib/CodeGen/GCMetadata.cpp | 44 +++++++++++++++++--------------- lib/CodeGen/GCMetadataPrinter.cpp | 2 +- lib/CodeGen/GCStrategy.cpp | 19 ++++++-------- lib/Target/X86/X86CodeEmitter.cpp | 2 +- 7 files changed, 40 insertions(+), 44 deletions(-) diff --git a/include/llvm/CodeGen/GCMetadata.h b/include/llvm/CodeGen/GCMetadata.h index 04fd8bed97..783f636740 100644 --- a/include/llvm/CodeGen/GCMetadata.h +++ b/include/llvm/CodeGen/GCMetadata.h @@ -38,12 +38,10 @@ #include "llvm/ADT/StringMap.h" namespace llvm { - class AsmPrinter; class GCStrategy; class Constant; - class MCAsmInfo; - + class MCSymbol; namespace GC { /// PointKind - The type of a collector-safe point. @@ -60,9 +58,9 @@ namespace llvm { /// struct GCPoint { GC::PointKind Kind; //< The kind of the safe point. - unsigned Num; //< Usually a label. + MCSymbol *Label; //< A label. - GCPoint(GC::PointKind K, unsigned N) : Kind(K), Num(N) {} + GCPoint(GC::PointKind K, MCSymbol *L) : Kind(K), Label(L) {} }; /// GCRoot - Metadata for a pointer to an object managed by the garbage @@ -123,8 +121,8 @@ namespace llvm { /// addSafePoint - Notes the existence of a safe point. Num is the ID of the /// label just prior to the safe point (if the code generator is using /// MachineModuleInfo). - void addSafePoint(GC::PointKind Kind, unsigned Num) { - SafePoints.push_back(GCPoint(Kind, Num)); + void addSafePoint(GC::PointKind Kind, MCSymbol *Label) { + SafePoints.push_back(GCPoint(Kind, Label)); } /// getFrameSize/setFrameSize - Records the function's frame size. diff --git a/include/llvm/CodeGen/GCMetadataPrinter.h b/include/llvm/CodeGen/GCMetadataPrinter.h index ff1a205adb..62875c398b 100644 --- a/include/llvm/CodeGen/GCMetadataPrinter.h +++ b/include/llvm/CodeGen/GCMetadataPrinter.h @@ -28,6 +28,7 @@ namespace llvm { class GCMetadataPrinter; class raw_ostream; + class MCAsmInfo; /// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the /// defaults from Registry. diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 31151f304a..66a2eee7a7 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1558,9 +1558,7 @@ void AsmPrinter::printLabelInst(const MachineInstr *MI) const { if (MI->getOperand(0).isMCSymbol()) Sym = MI->getOperand(0).getMCSymbol(); else - Sym = - OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) + - "label" + Twine(MI->getOperand(0).getImm())); + Sym = MMI->getLabelSym(MI->getOperand(0).getImm()); OutStreamer.EmitLabel(Sym); } diff --git a/lib/CodeGen/GCMetadata.cpp b/lib/CodeGen/GCMetadata.cpp index 055172b4e0..ab0a800225 100644 --- a/lib/CodeGen/GCMetadata.cpp +++ b/lib/CodeGen/GCMetadata.cpp @@ -17,6 +17,7 @@ #include "llvm/Pass.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Function.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -150,30 +151,31 @@ static const char *DescKind(GC::PointKind Kind) { } bool Printer::runOnFunction(Function &F) { - if (!F.hasGC()) { - GCFunctionInfo *FD = &getAnalysis().getFunctionInfo(F); + if (F.hasGC()) return false; + + GCFunctionInfo *FD = &getAnalysis().getFunctionInfo(F); + + OS << "GC roots for " << FD->getFunction().getNameStr() << ":\n"; + for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(), + RE = FD->roots_end(); RI != RE; ++RI) + OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n"; + + OS << "GC safe points for " << FD->getFunction().getNameStr() << ":\n"; + for (GCFunctionInfo::iterator PI = FD->begin(), + PE = FD->end(); PI != PE; ++PI) { - OS << "GC roots for " << FD->getFunction().getNameStr() << ":\n"; - for (GCFunctionInfo::roots_iterator RI = FD->roots_begin(), - RE = FD->roots_end(); RI != RE; ++RI) - OS << "\t" << RI->Num << "\t" << RI->StackOffset << "[sp]\n"; + OS << "\t" << PI->Label->getName() << ": " + << DescKind(PI->Kind) << ", live = {"; - OS << "GC safe points for " << FD->getFunction().getNameStr() << ":\n"; - for (GCFunctionInfo::iterator PI = FD->begin(), - PE = FD->end(); PI != PE; ++PI) { - - OS << "\tlabel " << PI->Num << ": " << DescKind(PI->Kind) << ", live = {"; - - for (GCFunctionInfo::live_iterator RI = FD->live_begin(PI), - RE = FD->live_end(PI);;) { - OS << " " << RI->Num; - if (++RI == RE) - break; - OS << ","; - } - - OS << " }\n"; + for (GCFunctionInfo::live_iterator RI = FD->live_begin(PI), + RE = FD->live_end(PI);;) { + OS << " " << RI->Num; + if (++RI == RE) + break; + OS << ","; } + + OS << " }\n"; } return false; diff --git a/lib/CodeGen/GCMetadataPrinter.cpp b/lib/CodeGen/GCMetadataPrinter.cpp index 9cd2925e2d..07fbb4bea6 100644 --- a/lib/CodeGen/GCMetadataPrinter.cpp +++ b/lib/CodeGen/GCMetadataPrinter.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/GCMetadataPrinter.h" - +class MCAsmInfo; using namespace llvm; GCMetadataPrinter::GCMetadataPrinter() { } diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp index b5006fdbb4..69db77f4fb 100644 --- a/lib/CodeGen/GCStrategy.cpp +++ b/lib/CodeGen/GCStrategy.cpp @@ -71,9 +71,9 @@ namespace { void FindSafePoints(MachineFunction &MF); void VisitCallPoint(MachineBasicBlock::iterator MI); - unsigned InsertLabel(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - DebugLoc DL) const; + MCSymbol *InsertLabel(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + DebugLoc DL) const; void FindStackOffsets(MachineFunction &MF); @@ -329,14 +329,11 @@ void MachineCodeAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); } -unsigned MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MI, - DebugLoc DL) const { - unsigned Label = MMI->NextLabelID(); - - BuildMI(MBB, MI, DL, - TII->get(TargetOpcode::GC_LABEL)).addImm(Label); - +MCSymbol *MachineCodeAnalysis::InsertLabel(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + DebugLoc DL) const { + MCSymbol *Label = MMI->getLabelSym(MMI->NextLabelID()); + BuildMI(MBB, MI, DL, TII->get(TargetOpcode::GC_LABEL)).addSym(Label); return Label; } diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index d5ecd3b72e..1c6f754740 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -603,9 +603,9 @@ void Emitter::emitInstruction(const MachineInstr &MI, llvm_report_error("JIT does not support inline asm!"); break; case TargetOpcode::DBG_LABEL: - case TargetOpcode::GC_LABEL: MCE.emitLabel(MMI->getLabelSym(MI.getOperand(0).getImm())); break; + case TargetOpcode::GC_LABEL: case TargetOpcode::EH_LABEL: MCE.emitLabel(MI.getOperand(0).getMCSymbol()); break; -- cgit v1.2.3