Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: lib/Transforms/NaCl/ReplacePtrsWithInts.cpp

Issue 1151093004: Changes from 3.7 merge to files not in upstream (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
diff --git a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
index 53f0d1d809e9b89f52d486c10eb67e21c5c33926..d1fab1fe9f22ee1cf204bf4cc5df4f9de364a1db 100644
--- a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
+++ b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
@@ -283,24 +283,6 @@ void FunctionConverter::eraseReplacedInstructions() {
}
}
-static void ConvertMetadataOperand(FunctionConverter *FC,
- IntrinsicInst *Call, int Index) {
- MDNode *MD = cast<MDNode>(Call->getArgOperand(Index));
- if (MD->getNumOperands() != 1)
- return;
- Value *MDArg = MD->getOperand(0);
- if (MDArg && (isa<Argument>(MDArg) || isa<Instruction>(MDArg))) {
- MDArg = FC->convert(MDArg, /* BypassPlaceholder= */ true);
- if (PtrToIntInst *Cast = dyn_cast<PtrToIntInst>(MDArg)) {
- // Unwrapping this is necessary for llvm.dbg.declare to work.
- MDArg = Cast->getPointerOperand();
- }
- SmallVector<Value *, 1> Args;
- Args.push_back(MDArg);
- Call->setArgOperand(Index, MDNode::get(Call->getContext(), Args));
- }
-}
-
// Remove attributes that only apply to pointer arguments. Returns
// the updated AttributeSet.
static AttributeSet RemovePointerAttrs(LLVMContext &Context,
@@ -333,6 +315,7 @@ static AttributeSet RemovePointerAttrs(LLVMContext &Context,
case Attribute::ReadOnly:
case Attribute::NonNull:
case Attribute::Dereferenceable:
+ case Attribute::DereferenceableOrNull:
break;
default:
AB.addAttribute(*Attr);
@@ -591,25 +574,12 @@ bool ReplacePtrsWithInts::runOnModule(Module &M) {
ConvertInstruction(&DL, IntPtrType, &FC, Iter++);
}
}
- // Now that all the replacement instructions have been created, we
jvoung (off chromium) 2015/05/26 20:39:45 this is automatic now?
Derek Schuff 2015/05/26 22:01:32 RAUW seems to work on MetadataAsValue. We could ma
- // can update the debug intrinsic calls.
- for (Function::iterator BB = NewFunc->begin(), E = NewFunc->end();
- BB != E; ++BB) {
- for (BasicBlock::iterator Inst = BB->begin(), E = BB->end();
- Inst != E; ++Inst) {
- if (IntrinsicInst *Call = dyn_cast<IntrinsicInst>(Inst)) {
- if (Call->getIntrinsicID() == Intrinsic::dbg_declare) {
- ConvertMetadataOperand(&FC, Call, 0);
- }
- }
- }
- }
FC.eraseReplacedInstructions();
// Patch the pointer to LLVM function in debug info descriptor.
auto DI = FunctionDIs.find(OldFunc);
if (DI != FunctionDIs.end())
- DI->second.replaceFunction(NewFunc);
+ DI->second->replaceFunction(NewFunc);
OldFunc->eraseFromParent();
}

Powered by Google App Engine
This is Rietveld 408576698