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

Side by Side Diff: lib/Transforms/NaCl/ReplacePtrsWithInts.cpp

Issue 1085483003: PNaCl: Check we don't crash in -replace-ptrs-with-ints with odd metadata operands. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 //===- ReplacePtrsWithInts.cpp - Convert pointer values to integer values--===// 1 //===- ReplacePtrsWithInts.cpp - Convert pointer values to integer values--===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This pass strips out aggregate pointer types and replaces them with 10 // This pass strips out aggregate pointer types and replaces them with
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 for (SmallVectorImpl<Instruction *>::iterator I = ToErase.begin(), 279 for (SmallVectorImpl<Instruction *>::iterator I = ToErase.begin(),
280 E = ToErase.end(); 280 E = ToErase.end();
281 I != E; ++I) { 281 I != E; ++I) {
282 (*I)->eraseFromParent(); 282 (*I)->eraseFromParent();
283 } 283 }
284 } 284 }
285 285
286 static void ConvertMetadataOperand(FunctionConverter *FC, 286 static void ConvertMetadataOperand(FunctionConverter *FC,
287 IntrinsicInst *Call, int Index) { 287 IntrinsicInst *Call, int Index) {
288 MDNode *MD = cast<MDNode>(Call->getArgOperand(Index)); 288 MDNode *MD = cast<MDNode>(Call->getArgOperand(Index));
289 if (!isa<MDNode>(MDVal->getMetadata())) {
290 return;
291 }
JF 2015/04/22 17:48:29 MDVal isn't a valid value here.
289 if (MD->getNumOperands() != 1) 292 if (MD->getNumOperands() != 1)
290 return; 293 return;
291 Value *MDArg = MD->getOperand(0); 294 Value *MDArg = MD->getOperand(0);
292 if (MDArg && (isa<Argument>(MDArg) || isa<Instruction>(MDArg))) { 295 if (MDArg && (isa<Argument>(MDArg) || isa<Instruction>(MDArg))) {
293 MDArg = FC->convert(MDArg, /* BypassPlaceholder= */ true); 296 MDArg = FC->convert(MDArg, /* BypassPlaceholder= */ true);
294 if (PtrToIntInst *Cast = dyn_cast<PtrToIntInst>(MDArg)) { 297 if (PtrToIntInst *Cast = dyn_cast<PtrToIntInst>(MDArg)) {
295 // Unwrapping this is necessary for llvm.dbg.declare to work. 298 // Unwrapping this is necessary for llvm.dbg.declare to work.
296 MDArg = Cast->getPointerOperand(); 299 MDArg = Cast->getPointerOperand();
297 } 300 }
298 SmallVector<Value *, 1> Args; 301 SmallVector<Value *, 1> Args;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // Delete the now-unused bitcast ConstantExprs that we created so 623 // Delete the now-unused bitcast ConstantExprs that we created so
621 // that they don't interfere with StripDeadPrototypes. 624 // that they don't interfere with StripDeadPrototypes.
622 Func->removeDeadConstantUsers(); 625 Func->removeDeadConstantUsers();
623 } 626 }
624 return true; 627 return true;
625 } 628 }
626 629
627 ModulePass *llvm::createReplacePtrsWithIntsPass() { 630 ModulePass *llvm::createReplacePtrsWithIntsPass() {
628 return new ReplacePtrsWithInts(); 631 return new ReplacePtrsWithInts();
629 } 632 }
OLDNEW
« no previous file with comments | « no previous file | test/Transforms/NaCl/replace-ptrs-with-ints.ll » ('j') | test/Transforms/NaCl/replace-ptrs-with-ints.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698