aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-14 02:33:54 +0000
committerChris Lattner <sabre@nondot.org>2010-03-14 02:33:54 +0000
commit7561d480953e0a2faa4af9be0a00b1180097c4bd (patch)
treeaaf49b3891269bd8c61d7a71b2f8d84e00466aac /lib/CodeGen
parent18589de9b1b8c157dea602653042e486128dd9e4 (diff)
downloadexternal_llvm-7561d480953e0a2faa4af9be0a00b1180097c4bd.tar.gz
external_llvm-7561d480953e0a2faa4af9be0a00b1180097c4bd.tar.bz2
external_llvm-7561d480953e0a2faa4af9be0a00b1180097c4bd.zip
change the LabelSDNode to be EHLabelSDNode and make it hold
an MCSymbol. Make the EH_LABEL MachineInstr hold its label with an MCSymbol instead of ID. Fix a bug in MMI.cpp which would return labels named "Label4" instead of "label4". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp7
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfException.cpp12
-rw-r--r--lib/CodeGen/MachineModuleInfo.cpp9
-rw-r--r--lib/CodeGen/SelectionDAG/InstrEmitter.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp15
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp12
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp17
7 files changed, 42 insertions, 37 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index b7cc5b3a21..31151f304a 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1553,7 +1553,12 @@ void AsmPrinter::printKill(const MachineInstr *MI) const {
/// printLabel - This method prints a local label used by debug and
/// exception handling tables.
void AsmPrinter::printLabelInst(const MachineInstr *MI) const {
- MCSymbol *Sym =
+ MCSymbol *Sym;
+
+ if (MI->getOperand(0).isMCSymbol())
+ Sym = MI->getOperand(0).getMCSymbol();
+ else
+ Sym =
OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) +
"label" + Twine(MI->getOperand(0).getImm()));
OutStreamer.EmitLabel(Sym);
diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp
index ff0aa80b1d..b5f7270ba5 100644
--- a/lib/CodeGen/AsmPrinter/DwarfException.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp
@@ -475,9 +475,15 @@ ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
continue;
}
- unsigned BeginLabelNo = MI->getOperand(0).getImm();
- assert(BeginLabelNo && "Invalid label!");
- MCSymbol *BeginLabel = getDWLabel("label", BeginLabelNo);
+ MCSymbol *BeginLabel;
+ if (MI->getOperand(0).isImm()) {
+ unsigned BeginLabelNo = MI->getOperand(0).getImm();
+ assert(BeginLabelNo && "Invalid label!");
+ BeginLabel = getDWLabel("label", BeginLabelNo);
+ } else {
+ BeginLabel = MI->getOperand(0).getMCSymbol();
+ }
+
// End of the previous try-range?
if (BeginLabel == LastLabel)
diff --git a/lib/CodeGen/MachineModuleInfo.cpp b/lib/CodeGen/MachineModuleInfo.cpp
index 42c6a7fef3..e7373711cb 100644
--- a/lib/CodeGen/MachineModuleInfo.cpp
+++ b/lib/CodeGen/MachineModuleInfo.cpp
@@ -73,7 +73,7 @@ bool MachineModuleInfo::doFinalization() {
/// getLabelSym - Turn a label ID into a symbol.
MCSymbol *MachineModuleInfo::getLabelSym(unsigned ID) {
return Context.GetOrCreateTemporarySymbol
- (Twine(Context.getAsmInfo().getPrivateGlobalPrefix()) + "Label" +Twine(ID));
+ (Twine(Context.getAsmInfo().getPrivateGlobalPrefix()) + "label" +Twine(ID));
}
/// EndFunction - Discard function meta information.
@@ -139,12 +139,11 @@ void MachineModuleInfo::addInvoke(MachineBasicBlock *LandingPad,
/// addLandingPad - Provide the label of a try LandingPad block.
///
-unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
- unsigned LandingPadID = NextLabelID();
- MCSymbol *LandingPadLabel = getLabelSym(LandingPadID);
+MCSymbol *MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) {
+ MCSymbol *LandingPadLabel = getLabelSym(NextLabelID());
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
LP.LandingPadLabel = LandingPadLabel;
- return LandingPadID;
+ return LandingPadLabel;
}
/// addPersonality - Provide the personality function for the exception
diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
index 223704305b..49105a8a9d 100644
--- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
+++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
@@ -705,6 +705,13 @@ void InstrEmitter::EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
EmitCopyFromReg(Node, 0, IsClone, IsCloned, SrcReg, VRBaseMap);
break;
}
+ case ISD::EH_LABEL: {
+ MCSymbol *S = cast<EHLabelSDNode>(Node)->getLabel();
+ BuildMI(*MBB, InsertPos, Node->getDebugLoc(),
+ TII->get(TargetOpcode::EH_LABEL)).addSym(S);
+ break;
+ }
+
case ISD::INLINEASM: {
unsigned NumOps = Node->getNumOperands();
if (Node->getOperand(NumOps-1).getValueType() == MVT::Flag)
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 58a475c0a8..1911103450 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1314,24 +1314,23 @@ SDValue SelectionDAG::getRegister(unsigned RegNo, EVT VT) {
return SDValue(N, 0);
}
-SDValue SelectionDAG::getLabel(unsigned Opcode, DebugLoc dl,
- SDValue Root,
- unsigned LabelID) {
+SDValue SelectionDAG::getEHLabel(DebugLoc dl, SDValue Root, MCSymbol *Label) {
FoldingSetNodeID ID;
SDValue Ops[] = { Root };
- AddNodeIDNode(ID, Opcode, getVTList(MVT::Other), &Ops[0], 1);
- ID.AddInteger(LabelID);
+ AddNodeIDNode(ID, ISD::EH_LABEL, getVTList(MVT::Other), &Ops[0], 1);
+ ID.AddPointer(Label);
void *IP = 0;
if (SDNode *E = CSEMap.FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
-
- SDNode *N = NodeAllocator.Allocate<LabelSDNode>();
- new (N) LabelSDNode(Opcode, dl, Root, LabelID);
+
+ SDNode *N = NodeAllocator.Allocate<EHLabelSDNode>();
+ new (N) EHLabelSDNode(dl, Root, Label);
CSEMap.InsertNode(N, IP);
AllNodes.push_back(N);
return SDValue(N, 0);
}
+
SDValue SelectionDAG::getBlockAddress(BlockAddress *BA, EVT VT,
bool isTarget,
unsigned char TargetFlags) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 08ba62b659..00ee13f7b1 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -4362,8 +4362,7 @@ void SelectionDAGBuilder::LowerCallTo(CallSite CS, SDValue Callee,
if (LandingPad && MMI) {
// Insert a label before the invoke call to mark the try range. This can be
// used to detect deletion of the invoke via the MachineModuleInfo.
- unsigned BeginLabelID = MMI->NextLabelID();
- BeginLabel = MMI->getLabelSym(BeginLabelID);
+ BeginLabel = MMI->getLabelSym(MMI->NextLabelID());
// For SjLj, keep track of which landing pads go with which invokes
// so as to maintain the ordering of pads in the LSDA.
@@ -4377,8 +4376,7 @@ void SelectionDAGBuilder::LowerCallTo(CallSite CS, SDValue Callee,
// Both PendingLoads and PendingExports must be flushed here;
// this call might not return.
(void)getRoot();
- DAG.setRoot(DAG.getLabel(ISD::EH_LABEL, getCurDebugLoc(),
- getControlRoot(), BeginLabelID));
+ DAG.setRoot(DAG.getEHLabel(getCurDebugLoc(), getControlRoot(), BeginLabel));
}
// Check if target-independent constraints permit a tail call here.
@@ -4466,10 +4464,8 @@ void SelectionDAGBuilder::LowerCallTo(CallSite CS, SDValue Callee,
if (LandingPad && MMI) {
// Insert a label at the end of the invoke call to mark the try range. This
// can be used to detect deletion of the invoke via the MachineModuleInfo.
- unsigned EndLabelID = MMI->NextLabelID();
- MCSymbol *EndLabel = MMI->getLabelSym(EndLabelID);
- DAG.setRoot(DAG.getLabel(ISD::EH_LABEL, getCurDebugLoc(),
- getRoot(), EndLabelID));
+ MCSymbol *EndLabel = MMI->getLabelSym(MMI->NextLabelID());
+ DAG.setRoot(DAG.getEHLabel(getCurDebugLoc(), getRoot(), EndLabel));
// Inform MachineModuleInfo of range.
MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index a82f0f71fe..ac71af5a78 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -879,10 +879,10 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
if (MMI && BB->isLandingPad()) {
// Add a label to mark the beginning of the landing pad. Deletion of the
// landing pad can thus be detected via the MachineModuleInfo.
- unsigned LabelID = MMI->addLandingPad(BB);
+ MCSymbol *Label = MMI->addLandingPad(BB);
const TargetInstrDesc &II = TII.get(TargetOpcode::EH_LABEL);
- BuildMI(BB, SDB->getCurDebugLoc(), II).addImm(LabelID);
+ BuildMI(BB, SDB->getCurDebugLoc(), II).addSym(Label);
// Mark exception register as live in.
unsigned Reg = TLI.getExceptionAddressRegister();
@@ -1517,14 +1517,6 @@ SDNode *SelectionDAGISel::Select_UNDEF(SDNode *N) {
return CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF,N->getValueType(0));
}
-SDNode *SelectionDAGISel::Select_EH_LABEL(SDNode *N) {
- SDValue Chain = N->getOperand(0);
- unsigned C = cast<LabelSDNode>(N)->getLabelID();
- SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32);
- return CurDAG->SelectNodeTo(N, TargetOpcode::EH_LABEL,
- MVT::Other, Tmp, Chain);
-}
-
/// GetVBR - decode a vbr encoding whose top bit is set.
ALWAYS_INLINE static uint64_t
GetVBR(uint64_t Val, const unsigned char *MatcherTable, unsigned &Idx) {
@@ -1651,7 +1643,8 @@ WalkChainUsers(SDNode *ChainedNode,
if (User->getOpcode() == ISD::CopyToReg ||
User->getOpcode() == ISD::CopyFromReg ||
- User->getOpcode() == ISD::INLINEASM) {
+ User->getOpcode() == ISD::INLINEASM ||
+ User->getOpcode() == ISD::EH_LABEL) {
// If their node ID got reset to -1 then they've already been selected.
// Treat them like a MachineOpcode.
if (User->getNodeId() == -1)
@@ -2055,6 +2048,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
case ISD::TokenFactor:
case ISD::CopyFromReg:
case ISD::CopyToReg:
+ case ISD::EH_LABEL:
NodeToMatch->setNodeId(-1); // Mark selected.
return 0;
case ISD::AssertSext:
@@ -2063,7 +2057,6 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
NodeToMatch->getOperand(0));
return 0;
case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch);
- case ISD::EH_LABEL: return Select_EH_LABEL(NodeToMatch);
case ISD::UNDEF: return Select_UNDEF(NodeToMatch);
}