IR: MDNode => Value: Instruction::getMetadata()

Change `Instruction::getMetadata()` to return `Value` as part of
PR21433.

Update most callers to use `Instruction::getMDNode()`, which wraps the
result in a `cast_or_null<MDNode>`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221024 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-11-01 00:10:31 +00:00
parent 9ed44978ef
commit 3a84a6377c
22 changed files with 82 additions and 85 deletions

View File

@ -141,14 +141,14 @@ public:
/// getMetadata - Get the metadata of given kind attached to this Instruction.
/// If the metadata is not found then return null.
MDNode *getMetadata(unsigned KindID) const {
Value *getMetadata(unsigned KindID) const {
if (!hasMetadata()) return nullptr;
return getMetadataImpl(KindID);
}
/// getMetadata - Get the metadata of given kind attached to this Instruction.
/// If the metadata is not found then return null.
MDNode *getMetadata(StringRef Kind) const {
Value *getMetadata(StringRef Kind) const {
if (!hasMetadata()) return nullptr;
return getMetadataImpl(Kind);
}
@ -289,8 +289,8 @@ private:
}
// These are all implemented in Metadata.cpp.
MDNode *getMetadataImpl(unsigned KindID) const;
MDNode *getMetadataImpl(StringRef Kind) const;
Value *getMetadataImpl(unsigned KindID) const;
Value *getMetadataImpl(StringRef Kind) const;
MDNode *getMDNodeImpl(unsigned KindID) const;
MDNode *getMDNodeImpl(StringRef Kind) const;
void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const;

View File

@ -180,7 +180,7 @@ bool BranchProbabilityInfo::calcMetadataWeights(BasicBlock *BB) {
if (!isa<BranchInst>(TI) && !isa<SwitchInst>(TI))
return false;
MDNode *WeightsNode = TI->getMetadata(LLVMContext::MD_prof);
MDNode *WeightsNode = TI->getMDNode(LLVMContext::MD_prof);
if (!WeightsNode)
return false;

View File

@ -235,7 +235,7 @@ bool Loop::isSafeToClone() const {
MDNode *Loop::getLoopID() const {
MDNode *LoopID = nullptr;
if (isLoopSimplifyForm()) {
LoopID = getLoopLatch()->getTerminator()->getMetadata(LoopMDName);
LoopID = getLoopLatch()->getTerminator()->getMDNode(LoopMDName);
} else {
// Go through each predecessor of the loop header and check the
// terminator for the metadata.
@ -247,7 +247,7 @@ MDNode *Loop::getLoopID() const {
// Check if this terminator branches to the loop header.
for (unsigned i = 0, ie = TI->getNumSuccessors(); i != ie; ++i) {
if (TI->getSuccessor(i) == H) {
MD = TI->getMetadata(LoopMDName);
MD = TI->getMDNode(LoopMDName);
break;
}
}
@ -309,7 +309,7 @@ bool Loop::isAnnotatedParallel() const {
// nested parallel loops). The loop identifier metadata refers to
// itself so we can check both cases with the same routine.
MDNode *loopIdMD =
II->getMetadata(LLVMContext::MD_mem_parallel_loop_access);
II->getMDNode(LLVMContext::MD_mem_parallel_loop_access);
if (!loopIdMD)
return false;

View File

@ -3668,7 +3668,7 @@ ScalarEvolution::GetMinTrailingZeros(const SCEV *S) {
/// metadata present in the IR.
static Optional<ConstantRange> GetRangeFromMetadata(Value *V) {
if (Instruction *I = dyn_cast<Instruction>(V)) {
if (MDNode *MD = I->getMetadata(LLVMContext::MD_range)) {
if (MDNode *MD = I->getMDNode(LLVMContext::MD_range)) {
ConstantRange TotalRange(
cast<IntegerType>(I->getType())->getBitWidth(), false);

View File

@ -213,13 +213,13 @@ ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS, const Location &Loc) {
if (!EnableScopedNoAlias)
return AliasAnalysis::getModRefInfo(CS, Loc);
if (!mayAliasInScopes(Loc.AATags.Scope,
CS.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
if (!mayAliasInScopes(Loc.AATags.Scope, CS.getInstruction()->getMDNode(
LLVMContext::MD_noalias)))
return NoModRef;
if (!mayAliasInScopes(
CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
Loc.AATags.NoAlias))
CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
Loc.AATags.NoAlias))
return NoModRef;
return AliasAnalysis::getModRefInfo(CS, Loc);
@ -231,13 +231,13 @@ ScopedNoAliasAA::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
return AliasAnalysis::getModRefInfo(CS1, CS2);
if (!mayAliasInScopes(
CS1.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
CS2.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
CS1.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
CS2.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
return NoModRef;
if (!mayAliasInScopes(
CS2.getInstruction()->getMetadata(LLVMContext::MD_alias_scope),
CS1.getInstruction()->getMetadata(LLVMContext::MD_noalias)))
CS2.getInstruction()->getMDNode(LLVMContext::MD_alias_scope),
CS1.getInstruction()->getMDNode(LLVMContext::MD_noalias)))
return NoModRef;
return AliasAnalysis::getModRefInfo(CS1, CS2);

View File

@ -493,7 +493,7 @@ TypeBasedAliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
// If this is an "immutable" type, we can assume the call doesn't write
// to memory.
if (const MDNode *M = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
if ((!isStructPathTBAA(M) && TBAANode(M).TypeIsImmutable()) ||
(isStructPathTBAA(M) && TBAAStructTagNode(M).TypeIsImmutable()))
Min = OnlyReadsMemory;
@ -514,8 +514,7 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS,
return AliasAnalysis::getModRefInfo(CS, Loc);
if (const MDNode *L = Loc.AATags.TBAA)
if (const MDNode *M =
CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
if (const MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
if (!Aliases(L, M))
return NoModRef;
@ -528,10 +527,9 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1,
if (!EnableTBAA)
return AliasAnalysis::getModRefInfo(CS1, CS2);
if (const MDNode *M1 =
CS1.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
if (const MDNode *M1 = CS1.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
if (const MDNode *M2 =
CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa))
CS2.getInstruction()->getMDNode(LLVMContext::MD_tbaa))
if (!Aliases(M1, M2))
return NoModRef;
@ -614,21 +612,21 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
if (Merge)
N.TBAA = MDNode::getMostGenericTBAA(N.TBAA,
getMetadata(LLVMContext::MD_tbaa));
N.TBAA =
MDNode::getMostGenericTBAA(N.TBAA, getMDNode(LLVMContext::MD_tbaa));
else
N.TBAA = getMetadata(LLVMContext::MD_tbaa);
N.TBAA = getMDNode(LLVMContext::MD_tbaa);
if (Merge)
N.Scope = MDNode::intersect(N.Scope,
getMetadata(LLVMContext::MD_alias_scope));
N.Scope =
MDNode::intersect(N.Scope, getMDNode(LLVMContext::MD_alias_scope));
else
N.Scope = getMetadata(LLVMContext::MD_alias_scope);
N.Scope = getMDNode(LLVMContext::MD_alias_scope);
if (Merge)
N.NoAlias = MDNode::intersect(N.NoAlias,
getMetadata(LLVMContext::MD_noalias));
N.NoAlias =
MDNode::intersect(N.NoAlias, getMDNode(LLVMContext::MD_noalias));
else
N.NoAlias = getMetadata(LLVMContext::MD_noalias);
N.NoAlias = getMDNode(LLVMContext::MD_noalias);
}

View File

@ -862,7 +862,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
switch (I->getOpcode()) {
default: break;
case Instruction::Load:
if (MDNode *MD = cast<LoadInst>(I)->getMetadata(LLVMContext::MD_range))
if (MDNode *MD = cast<LoadInst>(I)->getMDNode(LLVMContext::MD_range))
computeKnownBitsFromRangeMetadata(*MD, KnownZero);
break;
case Instruction::And: {
@ -1261,7 +1261,7 @@ void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne,
}
case Instruction::Call:
case Instruction::Invoke:
if (MDNode *MD = cast<Instruction>(I)->getMetadata(LLVMContext::MD_range))
if (MDNode *MD = cast<Instruction>(I)->getMDNode(LLVMContext::MD_range))
computeKnownBitsFromRangeMetadata(*MD, KnownZero);
// If a range metadata is attached to this IntrinsicInst, intersect the
// explicit range specified by the metadata and the implicit range of
@ -1536,7 +1536,7 @@ bool isKnownNonZero(Value *V, const DataLayout *TD, unsigned Depth,
}
if (Instruction* I = dyn_cast<Instruction>(V)) {
if (MDNode *Ranges = I->getMetadata(LLVMContext::MD_range)) {
if (MDNode *Ranges = I->getMDNode(LLVMContext::MD_range)) {
// If the possible ranges don't contain zero, then the value is
// definitely non-zero.
if (IntegerType* Ty = dyn_cast<IntegerType>(V->getType())) {

View File

@ -2122,9 +2122,9 @@ FastISel::createMachineMemOperandFor(const Instruction *I) const {
} else
return nullptr;
bool IsNonTemporal = I->getMetadata(LLVMContext::MD_nontemporal) != nullptr;
bool IsInvariant = I->getMetadata(LLVMContext::MD_invariant_load) != nullptr;
const MDNode *Ranges = I->getMetadata(LLVMContext::MD_range);
bool IsNonTemporal = I->getMDNode(LLVMContext::MD_nontemporal) != nullptr;
bool IsInvariant = I->getMDNode(LLVMContext::MD_invariant_load) != nullptr;
const MDNode *Ranges = I->getMDNode(LLVMContext::MD_range);
AAMDNodes AAInfo;
I->getAAMetadata(AAInfo);

View File

@ -3480,13 +3480,13 @@ void SelectionDAGBuilder::visitLoad(const LoadInst &I) {
Type *Ty = I.getType();
bool isVolatile = I.isVolatile();
bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
bool isInvariant = I.getMetadata(LLVMContext::MD_invariant_load) != nullptr;
bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
bool isInvariant = I.getMDNode(LLVMContext::MD_invariant_load) != nullptr;
unsigned Alignment = I.getAlignment();
AAMDNodes AAInfo;
I.getAAMetadata(AAInfo);
const MDNode *Ranges = I.getMetadata(LLVMContext::MD_range);
const MDNode *Ranges = I.getMDNode(LLVMContext::MD_range);
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
SmallVector<EVT, 4> ValueVTs;
@ -3584,7 +3584,7 @@ void SelectionDAGBuilder::visitStore(const StoreInst &I) {
NumValues));
EVT PtrVT = Ptr.getValueType();
bool isVolatile = I.isVolatile();
bool isNonTemporal = I.getMetadata(LLVMContext::MD_nontemporal) != nullptr;
bool isNonTemporal = I.getMDNode(LLVMContext::MD_nontemporal) != nullptr;
unsigned Alignment = I.getAlignment();
AAMDNodes AAInfo;
@ -6479,7 +6479,7 @@ void SelectionDAGBuilder::visitInlineAsm(ImmutableCallSite CS) {
// If we have a !srcloc metadata node associated with it, we want to attach
// this to the ultimately generated inline asm machineinstr. To do this, we
// pass in the third operand as this (potentially null) inline asm MDNode.
const MDNode *SrcLoc = CS.getInstruction()->getMetadata("srcloc");
const MDNode *SrcLoc = CS.getInstruction()->getMDNode("srcloc");
AsmNodeOperands.push_back(DAG.getMDNode(SrcLoc));
// Remember the HasSideEffect, AlignStack, AsmDialect, MayLoad and MayStore

View File

@ -579,7 +579,7 @@ void llvm::UpgradeCallsToIntrinsic(Function* F) {
}
void llvm::UpgradeInstWithTBAATag(Instruction *I) {
MDNode *MD = I->getMetadata(LLVMContext::MD_tbaa);
MDNode *MD = I->getMDNode(LLVMContext::MD_tbaa);
assert(MD && "UpgradeInstWithTBAATag should have a TBAA tag");
// Check if the tag uses struct-path aware TBAA format.
if (isa<MDNode>(MD->getOperand(0)) && MD->getNumOperands() >= 3)

View File

@ -96,7 +96,7 @@ DiagnosticInfoInlineAsm::DiagnosticInfoInlineAsm(const Instruction &I,
DiagnosticSeverity Severity)
: DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
Instr(&I) {
if (const MDNode *SrcLoc = I.getMetadata("srcloc")) {
if (const MDNode *SrcLoc = I.getMDNode("srcloc")) {
if (SrcLoc->getNumOperands() != 0)
if (const ConstantInt *CI = dyn_cast<ConstantInt>(SrcLoc->getOperand(0)))
LocCookie = CI->getZExtValue();

View File

@ -791,7 +791,7 @@ void BranchInst::swapSuccessors() {
// Update profile metadata if present and it matches our structural
// expectations.
MDNode *ProfileData = getMetadata(LLVMContext::MD_prof);
MDNode *ProfileData = getMDNode(LLVMContext::MD_prof);
if (!ProfileData || ProfileData->getNumOperands() != 3)
return;
@ -2072,8 +2072,7 @@ void BinaryOperator::andIRFlags(const Value *V) {
/// An accuracy of 0.0 means that the operation should be performed with the
/// default precision.
float FPMathOperator::getFPAccuracy() const {
const MDNode *MD =
cast<Instruction>(this)->getMetadata(LLVMContext::MD_fpmath);
const MDNode *MD = cast<Instruction>(this)->getMDNode(LLVMContext::MD_fpmath);
if (!MD)
return 0.0;
ConstantFP *Accuracy = cast<ConstantFP>(MD->getOperand(0));

View File

@ -605,16 +605,16 @@ void Instruction::setMetadata(StringRef Kind, Value *MD) {
setMetadata(getContext().getMDKindID(Kind), MD);
}
MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
Value *Instruction::getMetadataImpl(StringRef Kind) const {
return getMetadataImpl(getContext().getMDKindID(Kind));
}
MDNode *Instruction::getMDNodeImpl(unsigned KindID) const {
return getMetadataImpl(KindID);
return cast_or_null<MDNode>(getMetadataImpl(KindID));
}
MDNode *Instruction::getMDNodeImpl(StringRef Kind) const {
return getMetadataImpl(Kind);
return cast_or_null<MDNode>(getMetadataImpl(Kind));
}
void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
@ -729,7 +729,7 @@ void Instruction::setAAMetadata(const AAMDNodes &N) {
setMetadata(LLVMContext::MD_noalias, N.NoAlias);
}
MDNode *Instruction::getMetadataImpl(unsigned KindID) const {
Value *Instruction::getMetadataImpl(unsigned KindID) const {
// Handle 'dbg' as a special case since it is not stored in the hash table.
if (KindID == LLVMContext::MD_dbg)
return DbgLoc.getAsMDNode(getContext());

View File

@ -2267,7 +2267,7 @@ void Verifier::visitInstruction(Instruction &I) {
}
}
if (MDNode *MD = I.getMetadata(LLVMContext::MD_fpmath)) {
if (MDNode *MD = I.getMDNode(LLVMContext::MD_fpmath)) {
Assert1(I.getType()->isFPOrFPVectorTy(),
"fpmath requires a floating point result!", &I);
Assert1(MD->getNumOperands() == 1, "fpmath takes one operand!", &I);
@ -2281,7 +2281,7 @@ void Verifier::visitInstruction(Instruction &I) {
}
}
if (MDNode *Range = I.getMetadata(LLVMContext::MD_range)) {
if (MDNode *Range = I.getMDNode(LLVMContext::MD_range)) {
Assert1(isa<LoadInst>(I) || isa<CallInst>(I) || isa<InvokeInst>(I),
"Ranges are only for loads, calls and invokes!", &I);
visitRangeMetadata(I, Range, I.getType());
@ -2587,7 +2587,7 @@ void DebugInfoVerifier::verifyDebugInfo() {
void DebugInfoVerifier::processInstructions(DebugInfoFinder &Finder) {
for (const Function &F : *M)
for (auto I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
if (MDNode *MD = I->getMetadata(LLVMContext::MD_dbg))
if (MDNode *MD = I->getMDNode(LLVMContext::MD_dbg))
Finder.processLocation(*M, DILocation(MD));
if (const CallInst *CI = dyn_cast<CallInst>(&*I))
processCallInst(Finder, *CI);

View File

@ -319,7 +319,7 @@ bool llvm::getAlign(const Function &F, unsigned index, unsigned &align) {
}
bool llvm::getAlign(const CallInst &I, unsigned index, unsigned &align) {
if (MDNode *alignNode = I.getMetadata("callalign")) {
if (MDNode *alignNode = I.getMDNode("callalign")) {
for (int i = 0, n = alignNode->getNumOperands(); i < n; i++) {
if (const ConstantInt *CI =
dyn_cast<ConstantInt>(alignNode->getOperand(i))) {

View File

@ -117,7 +117,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
// If the memcpy has metadata describing the members, see if we can
// get the TBAA tag describing our copy.
if (MDNode *M = MI->getMetadata(LLVMContext::MD_tbaa_struct)) {
if (MDNode *M = MI->getMDNode(LLVMContext::MD_tbaa_struct)) {
if (M->getNumOperands() == 3 &&
M->getOperand(0) &&
isa<ConstantInt>(M->getOperand(0)) &&

View File

@ -231,7 +231,7 @@ bool ThreadSanitizer::doInitialization(Module &M) {
}
static bool isVtableAccess(Instruction *I) {
if (MDNode *Tag = I->getMetadata(LLVMContext::MD_tbaa))
if (MDNode *Tag = I->getMDNode(LLVMContext::MD_tbaa))
return Tag->isTBAAVtableAccess();
return false;
}

View File

@ -825,7 +825,7 @@ static MDString *AppendMDNodeToSourcePtr(unsigned NodeId,
// reference to said Node. Otherwise just return 0.
if (Instruction *Inst = dyn_cast<Instruction>(Ptr)) {
MDNode *Node;
if (!(Node = Inst->getMetadata(NodeId))) {
if (!(Node = Inst->getMDNode(NodeId))) {
// We do not have any node. Generate and attatch the hash MDString to the
// instruction.
@ -1736,7 +1736,7 @@ ObjCARCOpt::VisitInstructionBottomUp(Instruction *Inst,
NestingDetected = true;
}
MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
Sequence NewSeq = ReleaseMetadata ? S_MovableRelease : S_Release;
ANNOTATE_BOTTOMUP(Inst, Arg, S.GetSeq(), NewSeq);
S.ResetSequenceProgress(NewSeq);
@ -2017,7 +2017,7 @@ ObjCARCOpt::VisitInstructionTopDown(Instruction *Inst,
Sequence OldSeq = S.GetSeq();
MDNode *ReleaseMetadata = Inst->getMetadata(ImpreciseReleaseMDKind);
MDNode *ReleaseMetadata = Inst->getMDNode(ImpreciseReleaseMDKind);
switch (OldSeq) {
case S_Retain:

View File

@ -297,9 +297,9 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
for (Function::const_iterator I = CalledFunc->begin(), IE = CalledFunc->end();
I != IE; ++I)
for (BasicBlock::const_iterator J = I->begin(), JE = I->end(); J != JE; ++J) {
if (const MDNode *M = J->getMetadata(LLVMContext::MD_alias_scope))
if (const MDNode *M = J->getMDNode(LLVMContext::MD_alias_scope))
MD.insert(M);
if (const MDNode *M = J->getMetadata(LLVMContext::MD_noalias))
if (const MDNode *M = J->getMDNode(LLVMContext::MD_noalias))
MD.insert(M);
}
@ -359,33 +359,31 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) {
if (!NI)
continue;
if (MDNode *M = NI->getMetadata(LLVMContext::MD_alias_scope)) {
if (MDNode *M = NI->getMDNode(LLVMContext::MD_alias_scope)) {
MDNode *NewMD = MDMap[M];
// If the call site also had alias scope metadata (a list of scopes to
// which instructions inside it might belong), propagate those scopes to
// the inlined instructions.
if (MDNode *CSM =
CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope))
NewMD = MDNode::concatenate(NewMD, CSM);
NI->setMetadata(LLVMContext::MD_alias_scope, NewMD);
} else if (NI->mayReadOrWriteMemory()) {
if (MDNode *M =
CS.getInstruction()->getMetadata(LLVMContext::MD_alias_scope))
CS.getInstruction()->getMDNode(LLVMContext::MD_alias_scope))
NI->setMetadata(LLVMContext::MD_alias_scope, M);
}
if (MDNode *M = NI->getMetadata(LLVMContext::MD_noalias)) {
if (MDNode *M = NI->getMDNode(LLVMContext::MD_noalias)) {
MDNode *NewMD = MDMap[M];
// If the call site also had noalias metadata (a list of scopes with
// which instructions inside it don't alias), propagate those scopes to
// the inlined instructions.
if (MDNode *CSM =
CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
if (MDNode *CSM = CS.getInstruction()->getMDNode(LLVMContext::MD_noalias))
NewMD = MDNode::concatenate(NewMD, CSM);
NI->setMetadata(LLVMContext::MD_noalias, NewMD);
} else if (NI->mayReadOrWriteMemory()) {
if (MDNode *M =
CS.getInstruction()->getMetadata(LLVMContext::MD_noalias))
if (MDNode *M = CS.getInstruction()->getMDNode(LLVMContext::MD_noalias))
NI->setMetadata(LLVMContext::MD_noalias, M);
}
}
@ -589,9 +587,10 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
}
if (!NoAliases.empty())
NI->setMetadata(LLVMContext::MD_noalias, MDNode::concatenate(
NI->getMetadata(LLVMContext::MD_noalias),
MDNode::get(CalledFunc->getContext(), NoAliases)));
NI->setMetadata(LLVMContext::MD_noalias,
MDNode::concatenate(
NI->getMDNode(LLVMContext::MD_noalias),
MDNode::get(CalledFunc->getContext(), NoAliases)));
// Next, we want to figure out all of the sets to which we might belong.
// We might belong to a set if the noalias argument is in the set of
@ -614,9 +613,10 @@ static void AddAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap,
}
if (!Scopes.empty())
NI->setMetadata(LLVMContext::MD_alias_scope, MDNode::concatenate(
NI->getMetadata(LLVMContext::MD_alias_scope),
MDNode::get(CalledFunc->getContext(), Scopes)));
NI->setMetadata(
LLVMContext::MD_alias_scope,
MDNode::concatenate(NI->getMDNode(LLVMContext::MD_alias_scope),
MDNode::get(CalledFunc->getContext(), Scopes)));
}
}
}

View File

@ -128,7 +128,7 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions,
// Check to see if this branch is going to the same place as the default
// dest. If so, eliminate it as an explicit compare.
if (i.getCaseSuccessor() == DefaultDest) {
MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
unsigned NCases = SI->getNumCases();
// Fold the case metadata into the default if there will be any branches
// left, unless the metadata doesn't match the switch.
@ -206,7 +206,7 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions,
BranchInst *NewBr = Builder.CreateCondBr(Cond,
FirstCase.getCaseSuccessor(),
SI->getDefaultDest());
MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
if (MD && MD->getNumOperands() == 3) {
ConstantInt *SICase = dyn_cast<ConstantInt>(MD->getOperand(2));
ConstantInt *SIDef = dyn_cast<ConstantInt>(MD->getOperand(1));
@ -1313,7 +1313,7 @@ void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsign
K->getAllMetadataOtherThanDebugLoc(Metadata);
for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
unsigned Kind = Metadata[i].first;
MDNode *JMD = J->getMetadata(Kind);
MDNode *JMD = J->getMDNode(Kind);
MDNode *KMD = Metadata[i].second;
switch (Kind) {

View File

@ -643,7 +643,7 @@ SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
// Collect branch weights into a vector.
SmallVector<uint32_t, 8> Weights;
MDNode* MD = SI->getMetadata(LLVMContext::MD_prof);
MDNode *MD = SI->getMDNode(LLVMContext::MD_prof);
bool HasWeight = MD && (MD->getNumOperands() == 2 + SI->getNumCases());
if (HasWeight)
for (unsigned MD_i = 1, MD_e = MD->getNumOperands(); MD_i < MD_e;
@ -738,7 +738,7 @@ static int ConstantIntSortPredicate(ConstantInt *const *P1,
}
static inline bool HasBranchWeights(const Instruction* I) {
MDNode* ProfMD = I->getMetadata(LLVMContext::MD_prof);
MDNode *ProfMD = I->getMDNode(LLVMContext::MD_prof);
if (ProfMD && ProfMD->getOperand(0))
if (MDString* MDS = dyn_cast<MDString>(ProfMD->getOperand(0)))
return MDS->getString().equals("branch_weights");
@ -751,7 +751,7 @@ static inline bool HasBranchWeights(const Instruction* I) {
/// metadata.
static void GetBranchWeights(TerminatorInst *TI,
SmallVectorImpl<uint64_t> &Weights) {
MDNode* MD = TI->getMetadata(LLVMContext::MD_prof);
MDNode *MD = TI->getMDNode(LLVMContext::MD_prof);
assert(MD);
for (unsigned i = 1, e = MD->getNumOperands(); i < e; ++i) {
ConstantInt *CI = cast<ConstantInt>(MD->getOperand(i));
@ -1970,7 +1970,7 @@ static bool ExtractBranchMetadata(BranchInst *BI,
uint64_t &ProbTrue, uint64_t &ProbFalse) {
assert(BI->isConditional() &&
"Looking for probabilities on unconditional branch?");
MDNode *ProfileData = BI->getMetadata(LLVMContext::MD_prof);
MDNode *ProfileData = BI->getMDNode(LLVMContext::MD_prof);
if (!ProfileData || ProfileData->getNumOperands() != 3) return false;
ConstantInt *CITrue = dyn_cast<ConstantInt>(ProfileData->getOperand(1));
ConstantInt *CIFalse = dyn_cast<ConstantInt>(ProfileData->getOperand(2));

View File

@ -197,7 +197,7 @@ static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {
for (int i = 1, e = VL.size(); MD && i != e; i++) {
Instruction *I = cast<Instruction>(VL[i]);
MDNode *IMD = I->getMetadata(Kind);
MDNode *IMD = I->getMDNode(Kind);
switch (Kind) {
default: