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

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

Issue 940243003: PNaCl localmod mods in LLVM to 223109 (local files only) (Closed)
Patch Set: xx Created 5 years, 10 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 void FunctionConverter::recordConvertedAndErase(Instruction *From, Value *To) { 163 void FunctionConverter::recordConvertedAndErase(Instruction *From, Value *To) {
164 recordConverted(From, To); 164 recordConverted(From, To);
165 // There may still be references to this value, so defer deleting it. 165 // There may still be references to this value, so defer deleting it.
166 ToErase.push_back(From); 166 ToErase.push_back(From);
167 } 167 }
168 168
169 Value *FunctionConverter::stripNoopCasts(Value *Val) { 169 Value *FunctionConverter::stripNoopCasts(Value *Val) {
170 SmallPtrSet<Value *, 4> Visited; 170 SmallPtrSet<Value *, 4> Visited;
171 for (;;) { 171 for (;;) {
172 if (!Visited.insert(Val)) { 172 if (!Visited.insert(Val).second) {
173 // It is possible to get a circular reference in unreachable 173 // It is possible to get a circular reference in unreachable
174 // basic blocks. Handle this case for completeness. 174 // basic blocks. Handle this case for completeness.
175 return UndefValue::get(Val->getType()); 175 return UndefValue::get(Val->getType());
176 } 176 }
177 if (CastInst *Cast = dyn_cast<CastInst>(Val)) { 177 if (CastInst *Cast = dyn_cast<CastInst>(Val)) {
178 Value *Src = Cast->getOperand(0); 178 Value *Src = Cast->getOperand(0);
179 if ((isa<BitCastInst>(Cast) && Cast->getType()->isPointerTy()) || 179 if ((isa<BitCastInst>(Cast) && Cast->getType()->isPointerTy()) ||
180 (isa<PtrToIntInst>(Cast) && Cast->getType() == IntPtrType) || 180 (isa<PtrToIntInst>(Cast) && Cast->getType() == IntPtrType) ||
181 (isa<IntToPtrInst>(Cast) && Src->getType() == IntPtrType)) { 181 (isa<IntToPtrInst>(Cast) && Src->getType() == IntPtrType)) {
182 Val = Src; 182 Val = Src;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 // Delete the now-unused bitcast ConstantExprs that we created so 618 // Delete the now-unused bitcast ConstantExprs that we created so
619 // that they don't interfere with StripDeadPrototypes. 619 // that they don't interfere with StripDeadPrototypes.
620 Func->removeDeadConstantUsers(); 620 Func->removeDeadConstantUsers();
621 } 621 }
622 return true; 622 return true;
623 } 623 }
624 624
625 ModulePass *llvm::createReplacePtrsWithIntsPass() { 625 ModulePass *llvm::createReplacePtrsWithIntsPass() {
626 return new ReplacePtrsWithInts(); 626 return new ReplacePtrsWithInts();
627 } 627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698