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

Side by Side Diff: src/IceASanInstrumentation.cpp

Issue 2256903003: Subzero: Replace pointers to allocation functions in stores (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 382 }
383 } 383 }
384 Constant *Func = 384 Constant *Func =
385 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load")); 385 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load"));
386 instrumentAccess(Context, Instr->getSourceAddress(), 386 instrumentAccess(Context, Instr->getSourceAddress(),
387 typeWidthInBytes(Instr->getDest()->getType()), Func); 387 typeWidthInBytes(Instr->getDest()->getType()), Func);
388 } 388 }
389 389
390 void ASanInstrumentation::instrumentStore(LoweringContext &Context, 390 void ASanInstrumentation::instrumentStore(LoweringContext &Context,
391 InstStore *Instr) { 391 InstStore *Instr) {
392 Operand *Data = Instr->getData();
393 if (auto *Reloc = llvm::dyn_cast<ConstantRelocatable>(Data)) {
394 std::string DataName = Reloc->getName().toStringOrEmpty();
395 assert(!DataName.empty());
Jim Stichnoth 2016/08/18 13:17:19 I just realized that if you use this pattern: S
tlively 2016/08/18 15:17:48 Done.
396 StringMap::const_iterator DataSub = FuncSubstitutions.find(DataName);
397 if (DataSub != FuncSubstitutions.end()) {
398 auto *NewData = ConstantRelocatable::create(
399 Ctx, Reloc->getType(),
400 RelocatableTuple(Reloc->getOffset(), RelocOffsetArray(0),
401 Ctx->getGlobalString(DataSub->second),
402 Reloc->getEmitString()));
403 auto *NewStore = InstStore::create(Context.getNode()->getCfg(), NewData,
404 Instr->getAddr());
405 Instr->setDeleted();
406 Context.insert(NewStore);
407 Instr = NewStore;
408 }
409 }
Karl 2016/08/18 14:17:01 Minor nit. It appears that instrument load/store l
tlively 2016/08/18 15:17:48 Done.
392 Constant *Func = 410 Constant *Func =
393 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_store")); 411 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_store"));
394 instrumentAccess(Context, Instr->getAddr(), 412 instrumentAccess(Context, Instr->getAddr(),
395 typeWidthInBytes(Instr->getData()->getType()), Func); 413 typeWidthInBytes(Instr->getData()->getType()), Func);
396 } 414 }
397 415
398 void ASanInstrumentation::instrumentAccess(LoweringContext &Context, 416 void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
399 Operand *Op, SizeT Size, 417 Operand *Op, SizeT Size,
400 Constant *CheckFunc) { 418 Constant *CheckFunc) {
401 // Skip redundant checks within basic blocks 419 // Skip redundant checks within basic blocks
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName))); 490 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName)));
473 } 491 }
474 492
475 // TODO(tlively): make this more efficient with swap idiom 493 // TODO(tlively): make this more efficient with swap idiom
476 void ASanInstrumentation::finishFunc(Cfg *) { 494 void ASanInstrumentation::finishFunc(Cfg *) {
477 ICE_TLS_GET_FIELD(LocalVars)->clear(); 495 ICE_TLS_GET_FIELD(LocalVars)->clear();
478 ICE_TLS_GET_FIELD(LocalDtors)->clear(); 496 ICE_TLS_GET_FIELD(LocalDtors)->clear();
479 } 497 }
480 498
481 } // end of namespace Ice 499 } // 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