diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 51 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/IntrinsicInst.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 7 |
5 files changed, 38 insertions, 35 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 15ca1fa..59ba807 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -599,9 +599,7 @@ void DIVariable::dump() const { //===----------------------------------------------------------------------===// DIFactory::DIFactory(Module &m) - : M(m), VMContext(M.getContext()), DeclareFn(0) { - EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext)); -} + : M(m), VMContext(M.getContext()), DeclareFn(0) {} Constant *DIFactory::GetTagConstant(unsigned TAG) { assert((TAG & LLVMDebugVersionMask) == 0 && @@ -1034,26 +1032,22 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo, /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *InsertBefore) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertBefore); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); } /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, BasicBlock *InsertAtEnd) { - // Cast the storage to a {}* for the call to llvm.dbg.declare. - Storage = new BitCastInst(Storage, EmptyStructPtr, "", InsertAtEnd); - if (!DeclareFn) DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); - Value *Args[] = { Storage, D.getNode() }; + Value *Elts[] = { Storage }; + Value *Args[] = { MDNode::get(Storage->getContext(), Elts, 1), D.getNode() }; return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd); } @@ -1258,25 +1252,24 @@ Value *llvm::findDbgGlobalDeclare(GlobalVariable *V) { /// Finds the llvm.dbg.declare intrinsic corresponding to this value if any. /// It looks through pointer casts too. -const DbgDeclareInst *llvm::findDbgDeclare(const Value *V, bool stripCasts) { - if (stripCasts) { - V = V->stripPointerCasts(); - - // Look for the bitcast. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (isa<BitCastInst>(I)) { - const DbgDeclareInst *DDI = findDbgDeclare(*I, false); - if (DDI) return DDI; - } +const DbgDeclareInst *llvm::findDbgDeclare(const Value *V) { + V = V->stripPointerCasts(); + + if (!isa<Instruction>(V) && !isa<Argument>(V)) return 0; - } - - // Find llvm.dbg.declare among uses of the instruction. - for (Value::use_const_iterator I = V->use_begin(), E =V->use_end(); - I != E; ++I) - if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I)) - return DDI; + + const Function *F = NULL; + if (const Instruction *I = dyn_cast<Instruction>(V)) + F = I->getParent()->getParent(); + else if (const Argument *A = dyn_cast<Argument>(V)) + F = A->getParent(); + + for (Function::const_iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) + for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end(); + BI != BE; ++BI) + if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI)) + if (DDI->getAddress() == V) + return DDI; return 0; } diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 8bc95d3..09fd657 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -332,8 +332,6 @@ bool FastISel::SelectCall(User *I) { return true; Value *Address = DI->getAddress(); - if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address)) - Address = BCI->getOperand(0); AllocaInst *AI = dyn_cast<AllocaInst>(Address); // Don't handle byval struct arguments or VLAs, for example. if (!AI) break; diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index 2161841..5e4c9fb 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -521,7 +521,7 @@ void llvm::CheckDebugInfoIntrinsics(Module *M) { if (Function *Declare = M->getFunction("llvm.dbg.declare")) { if (!Declare->use_empty()) { DbgDeclareInst *DDI = cast<DbgDeclareInst>(Declare->use_back()); - if (!isa<MDNode>(DDI->getOperand(2))) { + if (!isa<MDNode>(DDI->getOperand(1)) ||!isa<MDNode>(DDI->getOperand(2))) { while (!Declare->use_empty()) { CallInst *CI = cast<CallInst>(Declare->use_back()); CI->eraseFromParent(); diff --git a/lib/VMCore/IntrinsicInst.cpp b/lib/VMCore/IntrinsicInst.cpp index cb9252e..d8f015a 100644 --- a/lib/VMCore/IntrinsicInst.cpp +++ b/lib/VMCore/IntrinsicInst.cpp @@ -51,6 +51,17 @@ Value *DbgInfoIntrinsic::StripCast(Value *C) { } //===----------------------------------------------------------------------===// +/// DbgDeclareInst - This represents the llvm.dbg.declare instruction. +/// + +Value *DbgDeclareInst::getAddress() const { + if (MDNode* MD = cast_or_null<MDNode>(getOperand(1))) + return MD->getOperand(0); + else + return NULL; +} + +//===----------------------------------------------------------------------===// /// DbgValueInst - This represents the llvm.dbg.value instruction. /// diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 66e2a67..ec475e4 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1590,9 +1590,10 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { default: break; case Intrinsic::dbg_declare: // llvm.dbg.declare - if (Constant *C = dyn_cast<Constant>(CI.getOperand(1))) - Assert1(C && !isa<ConstantPointerNull>(C), - "invalid llvm.dbg.declare intrinsic call", &CI); + if (MDNode *MD = dyn_cast<MDNode>(CI.getOperand(1))) + if (Constant *C = dyn_cast<Constant>(MD->getOperand(0))) + Assert1(C && !isa<ConstantPointerNull>(C), + "invalid llvm.dbg.declare intrinsic call", &CI); break; case Intrinsic::memcpy: case Intrinsic::memmove: |