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

Side by Side Diff: src/IceASanInstrumentation.cpp

Issue 2115693002: Implemented loose checking for potential widened loads (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Added FileCheck for wide load test Created 4 years, 5 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 | « src/IceASanInstrumentation.h ('k') | tests_lit/asan_tests/errors.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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 InstCall::create(Context.getNode()->getCfg(), Instr->getNumArgs(), 254 InstCall::create(Context.getNode()->getCfg(), Instr->getNumArgs(),
255 Instr->getDest(), NewFunc, Instr->isTailcall()); 255 Instr->getDest(), NewFunc, Instr->isTailcall());
256 for (SizeT I = 0, Args = Instr->getNumArgs(); I < Args; ++I) 256 for (SizeT I = 0, Args = Instr->getNumArgs(); I < Args; ++I)
257 NewCall->addArg(Instr->getArg(I)); 257 NewCall->addArg(Instr->getArg(I));
258 Context.insert(NewCall); 258 Context.insert(NewCall);
259 Instr->setDeleted(); 259 Instr->setDeleted();
260 } 260 }
261 261
262 void ASanInstrumentation::instrumentLoad(LoweringContext &Context, 262 void ASanInstrumentation::instrumentLoad(LoweringContext &Context,
263 InstLoad *Instr) { 263 InstLoad *Instr) {
264 Constant *Func =
265 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_load"));
264 instrumentAccess(Context, Instr->getSourceAddress(), 266 instrumentAccess(Context, Instr->getSourceAddress(),
265 typeWidthInBytes(Instr->getDest()->getType())); 267 typeWidthInBytes(Instr->getDest()->getType()), Func);
266 } 268 }
267 269
268 void ASanInstrumentation::instrumentStore(LoweringContext &Context, 270 void ASanInstrumentation::instrumentStore(LoweringContext &Context,
269 InstStore *Instr) { 271 InstStore *Instr) {
272 Constant *Func =
273 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check_store"));
270 instrumentAccess(Context, Instr->getAddr(), 274 instrumentAccess(Context, Instr->getAddr(),
271 typeWidthInBytes(Instr->getData()->getType())); 275 typeWidthInBytes(Instr->getData()->getType()), Func);
272 } 276 }
273 277
274 // TODO(tlively): Take size of access into account as well 278 // TODO(tlively): Take size of access into account as well
275 void ASanInstrumentation::instrumentAccess(LoweringContext &Context, 279 void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
276 Operand *Op, SizeT Size) { 280 Operand *Op, SizeT Size,
277 Constant *AccessCheck = 281 Constant *CheckFunc) {
278 Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check"));
279 constexpr SizeT NumArgs = 2; 282 constexpr SizeT NumArgs = 2;
280 constexpr Variable *Void = nullptr; 283 constexpr Variable *Void = nullptr;
281 constexpr bool NoTailCall = false; 284 constexpr bool NoTailCall = false;
282 auto *Call = InstCall::create(Context.getNode()->getCfg(), NumArgs, Void, 285 auto *Call = InstCall::create(Context.getNode()->getCfg(), NumArgs, Void,
283 AccessCheck, NoTailCall); 286 CheckFunc, NoTailCall);
284 Call->addArg(Op); 287 Call->addArg(Op);
285 Call->addArg(ConstantInteger32::create(Ctx, IceType_i32, Size)); 288 Call->addArg(ConstantInteger32::create(Ctx, IceType_i32, Size));
286 // play games to insert the call before the access instruction 289 // play games to insert the call before the access instruction
287 InstList::iterator Next = Context.getNext(); 290 InstList::iterator Next = Context.getNext();
288 Context.setInsertPoint(Context.getCur()); 291 Context.setInsertPoint(Context.getCur());
289 Context.insert(Call); 292 Context.insert(Call);
290 Context.setNext(Next); 293 Context.setNext(Next);
291 } 294 }
292 295
293 void ASanInstrumentation::instrumentRet(LoweringContext &Context, InstRet *) { 296 void ASanInstrumentation::instrumentRet(LoweringContext &Context, InstRet *) {
(...skipping 26 matching lines...) Expand all
320 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName))); 323 Call->addArg(Ctx->getConstantSym(0, Ctx->getGlobalString(RzSizesName)));
321 } 324 }
322 325
323 // TODO(tlively): make this more efficient with swap idiom 326 // TODO(tlively): make this more efficient with swap idiom
324 void ASanInstrumentation::finishFunc(Cfg *Func) { 327 void ASanInstrumentation::finishFunc(Cfg *Func) {
325 (void)Func; 328 (void)Func;
326 ICE_TLS_GET_FIELD(LocalDtors)->clear(); 329 ICE_TLS_GET_FIELD(LocalDtors)->clear();
327 } 330 }
328 331
329 } // end of namespace Ice 332 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceASanInstrumentation.h ('k') | tests_lit/asan_tests/errors.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698