This is a major cleanup of the instruction metadata interfaces that

I asked Devang to do back on Sep 27.  Instead of going through the
MetadataContext class with methods like getMD() and getMDs(), just
ask the instruction directly for its metadata with getMetadata()
and getAllMetadata().

This includes a variety of other fixes and improvements: previously
all Value*'s were bloated because the HasMetadata bit was thrown into
value, adding a 9th bit to a byte.  Now this is properly sunk down to
the Instruction class (the only place where it makes sense) and it
will be folded away somewhere soon.

This also fixes some confusion in getMDs and its clients about 
whether the returned list is indexed by the MDID or densely packed.
This is now returned sorted and densely packed and the comments make
this clear.

This introduces a number of fixme's which I'll follow up on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92235 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-12-28 23:41:32 +00:00
parent f309880ad8
commit 3990b121cf
18 changed files with 291 additions and 276 deletions

View File

@@ -43,7 +43,6 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
#include "llvm/CodeGen/FastISel.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
@@ -349,10 +348,7 @@ bool FastISel::SelectCall(User *I) {
if (SI == StaticAllocaMap.end()) break; // VLAs.
int FI = SI->second;
if (MMI) {
MetadataContext &TheMetadata =
DI->getParent()->getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, DI))
if (MDNode *Dbg = DI->getMetadata("dbg"))
MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
}
return true;

View File

@@ -27,7 +27,6 @@
#include "llvm/Instructions.h"
#include "llvm/Intrinsics.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/CodeGen/FastISel.h"
#include "llvm/CodeGen/GCStrategy.h"
@@ -4379,14 +4378,9 @@ SelectionDAGBuilder::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
return 0; // VLAs.
int FI = SI->second;
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
if (MMI) {
MetadataContext &TheMetadata =
DI.getParent()->getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKindID("dbg");
if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, &DI))
if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo())
if (MDNode *Dbg = DI.getMetadata("dbg"))
MMI->setVariableDbgInfo(Variable, FI, Dbg);
}
return 0;
}
case Intrinsic::eh_exception: {

View File

@@ -362,12 +362,12 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
/// SetDebugLoc - Update MF's and SDB's DebugLocs if debug information is
/// attached with this instruction.
static void SetDebugLoc(unsigned MDDbgKind, MetadataContext &TheMetadata,
Instruction *I, SelectionDAGBuilder *SDB,
static void SetDebugLoc(unsigned MDDbgKind, Instruction *I,
SelectionDAGBuilder *SDB,
FastISel *FastIS, MachineFunction *MF) {
if (isa<DbgInfoIntrinsic>(I)) return;
if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) {
if (MDNode *Dbg = I->getMetadata(MDDbgKind)) {
DILocation DILoc(Dbg);
DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo());
@@ -384,8 +384,7 @@ static void SetDebugLoc(unsigned MDDbgKind, MetadataContext &TheMetadata,
}
/// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown.
static void ResetDebugLoc(SelectionDAGBuilder *SDB,
FastISel *FastIS) {
static void ResetDebugLoc(SelectionDAGBuilder *SDB, FastISel *FastIS) {
SDB->setCurDebugLoc(DebugLoc::getUnknownLoc());
if (FastIS)
FastIS->setCurDebugLoc(DebugLoc::getUnknownLoc());
@@ -402,7 +401,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
// Lower all of the non-terminator instructions. If a call is emitted
// as a tail call, cease emitting nodes for this block.
for (BasicBlock::iterator I = Begin; I != End && !SDB->HasTailCall; ++I) {
SetDebugLoc(MDDbgKind, TheMetadata, I, SDB, 0, MF);
SetDebugLoc(MDDbgKind, I, SDB, 0, MF);
if (!isa<TerminatorInst>(I)) {
SDB->visit(*I);
@@ -425,7 +424,7 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
HandlePHINodesInSuccessorBlocks(LLVMBB);
// Lower the terminator after the copies are emitted.
SetDebugLoc(MDDbgKind, TheMetadata, LLVMBB->getTerminator(), SDB, 0, MF);
SetDebugLoc(MDDbgKind, LLVMBB->getTerminator(), SDB, 0, MF);
SDB->visit(*LLVMBB->getTerminator());
ResetDebugLoc(SDB, 0);
}
@@ -776,7 +775,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
break;
}
SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF);
SetDebugLoc(MDDbgKind, BI, SDB, FastIS, &MF);
// First try normal tablegen-generated "fast" selection.
if (FastIS->SelectInstruction(BI)) {