Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |