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

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

Issue 17777004: Concurrency support for PNaCl ABI (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Fix bad merge. Created 7 years, 5 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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 unsigned Alignment = Alloca->getAlignment(); 476 unsigned Alignment = Alloca->getAlignment();
477 if (Alignment == 0) 477 if (Alignment == 0)
478 Alignment = DL->getPrefTypeAlignment(ElementTy); 478 Alignment = DL->getPrefTypeAlignment(ElementTy);
479 Value *Tmp = CopyDebug(new AllocaInst(Type::getInt8Ty(Inst->getContext()), 479 Value *Tmp = CopyDebug(new AllocaInst(Type::getInt8Ty(Inst->getContext()),
480 MulSize, Alignment, "", Inst), 480 MulSize, Alignment, "", Inst),
481 Inst); 481 Inst);
482 Tmp->takeName(Alloca); 482 Tmp->takeName(Alloca);
483 Value *Alloca2 = new PtrToIntInst(Tmp, IntPtrType, 483 Value *Alloca2 = new PtrToIntInst(Tmp, IntPtrType,
484 Tmp->getName() + ".asint", Inst); 484 Tmp->getName() + ".asint", Inst);
485 FC->recordConvertedAndErase(Alloca, Alloca2); 485 FC->recordConvertedAndErase(Alloca, Alloca2);
486 } else if (// These atomics only operate on integer pointers, not 486 } else if (// Handle these instructions as a convenience to allow
487 // other pointers, so we don't need to recreate the
488 // instruction.
489 isa<AtomicCmpXchgInst>(Inst) ||
490 isa<AtomicRMWInst>(Inst) ||
491 // Handle these instructions as a convenience to allow
492 // the pass to be used in more situations, even though we 487 // the pass to be used in more situations, even though we
493 // don't expect them in PNaCl's stable ABI. 488 // don't expect them in PNaCl's stable ABI.
494 isa<GetElementPtrInst>(Inst) || 489 isa<GetElementPtrInst>(Inst) ||
495 isa<VAArgInst>(Inst) || 490 isa<VAArgInst>(Inst) ||
496 isa<IndirectBrInst>(Inst) || 491 isa<IndirectBrInst>(Inst) ||
497 isa<ExtractValueInst>(Inst) || 492 isa<ExtractValueInst>(Inst) ||
498 isa<InsertValueInst>(Inst)) { 493 isa<InsertValueInst>(Inst) ||
494 // These atomics only operate on integer pointers, not
495 // other pointers, so we don't need to recreate the
496 // instruction.
497 isa<AtomicCmpXchgInst>(Inst) ||
498 isa<AtomicRMWInst>(Inst)) {
499 FC->convertInPlace(Inst); 499 FC->convertInPlace(Inst);
500 } 500 }
501 } 501 }
502 502
503 // Convert ptrtoint+inttoptr to a bitcast because it's shorter and 503 // Convert ptrtoint+inttoptr to a bitcast because it's shorter and
504 // because some intrinsics work on bitcasts but not on 504 // because some intrinsics work on bitcasts but not on
505 // ptrtoint+inttoptr, in particular: 505 // ptrtoint+inttoptr, in particular:
506 // * llvm.lifetime.start/end (although we strip these out) 506 // * llvm.lifetime.start/end (although we strip these out)
507 // * llvm.eh.typeid.for 507 // * llvm.eh.typeid.for
508 static void SimplifyCasts(Instruction *Inst, Type *IntPtrType) { 508 static void SimplifyCasts(Instruction *Inst, Type *IntPtrType) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 // Delete the now-unused bitcast ConstantExprs that we created so 613 // Delete the now-unused bitcast ConstantExprs that we created so
614 // that they don't interfere with StripDeadPrototypes. 614 // that they don't interfere with StripDeadPrototypes.
615 Func->removeDeadConstantUsers(); 615 Func->removeDeadConstantUsers();
616 } 616 }
617 return true; 617 return true;
618 } 618 }
619 619
620 ModulePass *llvm::createReplacePtrsWithIntsPass() { 620 ModulePass *llvm::createReplacePtrsWithIntsPass() {
621 return new ReplacePtrsWithInts(); 621 return new ReplacePtrsWithInts();
622 } 622 }
OLDNEW
« no previous file with comments | « lib/Transforms/NaCl/PNaClABISimplify.cpp ('k') | lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698