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

Side by Side Diff: src/IceASanInstrumentation.cpp

Issue 2241383006: Subzero: Replace pointers to allocation functions in loads (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fixed comment Created 4 years, 4 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
« no previous file with comments | « no previous file | tests_lit/asan_tests/localreplacement.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceASanInstrumentation.cpp - ASan ------------*- C++ -*-===// 1 //===- subzero/src/IceASanInstrumentation.cpp - ASan ------------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 /// \file 10 /// \file
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 InstCall::create(Context.getNode()->getCfg(), Instr->getNumArgs(), 356 InstCall::create(Context.getNode()->getCfg(), Instr->getNumArgs(),
357 Instr->getDest(), NewFunc, Instr->isTailcall()); 357 Instr->getDest(), NewFunc, Instr->isTailcall());
358 for (SizeT I = 0, Args = Instr->getNumArgs(); I < Args; ++I) 358 for (SizeT I = 0, Args = Instr->getNumArgs(); I < Args; ++I)
359 NewCall->addArg(Instr->getArg(I)); 359 NewCall->addArg(Instr->getArg(I));
360 Context.insert(NewCall); 360 Context.insert(NewCall);
361 Instr->setDeleted(); 361 Instr->setDeleted();
362 } 362 }
363 363
364 void ASanInstrumentation::instrumentLoad(LoweringContext &Context, 364 void ASanInstrumentation::instrumentLoad(LoweringContext &Context,
365 InstLoad *Instr) { 365 InstLoad *Instr) {
366 Operand *Src = Instr->getSourceAddress();
367 if (auto *Reloc = llvm::dyn_cast<ConstantRelocatable>(Src)) {
368 std::string SrcName = Reloc->getName().toStringOrEmpty();
369 assert(!SrcName.empty());
370 StringMap::const_iterator SrcSub = FuncSubstitutions.find(SrcName);
371 if (SrcSub != FuncSubstitutions.end()) {
372 auto *NewSrc = ConstantRelocatable::create(
373 Ctx, Reloc->getType(),
374 RelocatableTuple(Reloc->getOffset(), RelocOffsetArray(0),
375 Ctx->getGlobalString(SrcSub->second),
376 Reloc->getEmitString()));
377 auto *NewLoad = InstLoad::create(Context.getNode()->getCfg(),
378 Instr->getDest(), NewSrc);
379 Instr->setDeleted();
380 Context.insert(NewLoad);
381 Instr = NewLoad;
382 }
383 }
366 Constant *Func = 384 Constant *Func =
367 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load")); 385 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load"));
368 instrumentAccess(Context, Instr->getSourceAddress(), 386 instrumentAccess(Context, Instr->getSourceAddress(),
369 typeWidthInBytes(Instr->getDest()->getType()), Func); 387 typeWidthInBytes(Instr->getDest()->getType()), Func);
370 } 388 }
371 389
372 void ASanInstrumentation::instrumentStore(LoweringContext &Context, 390 void ASanInstrumentation::instrumentStore(LoweringContext &Context,
373 InstStore *Instr) { 391 InstStore *Instr) {
374 Constant *Func = 392 Constant *Func =
375 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_store")); 393 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_store"));
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName))); 472 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName)));
455 } 473 }
456 474
457 // TODO(tlively): make this more efficient with swap idiom 475 // TODO(tlively): make this more efficient with swap idiom
458 void ASanInstrumentation::finishFunc(Cfg *) { 476 void ASanInstrumentation::finishFunc(Cfg *) {
459 ICE_TLS_GET_FIELD(LocalVars)->clear(); 477 ICE_TLS_GET_FIELD(LocalVars)->clear();
460 ICE_TLS_GET_FIELD(LocalDtors)->clear(); 478 ICE_TLS_GET_FIELD(LocalDtors)->clear();
461 } 479 }
462 480
463 } // end of namespace Ice 481 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/asan_tests/localreplacement.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698