| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |