[PATCH] D34789: Copy arguments passed by value into explicit allocas for ASan
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 11:58:10 PDT 2017
eugenis added inline comments.
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:2544
+ Instruction *InsBefore = dyn_cast<Instruction>(FirstBB.getFirstInsertionPt());
+ IRBuilder<> IRB(InsBefore);
+ for (Argument &Arg : F.args()) {
----------------
You can avoid the cast by using this constructor: http://llvm-cs.pcc.me.uk/include/llvm/IR/IRBuilder.h#703
IRBuilder(BB, BB.getFirstInsertionPt());
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:2551
+ AllocaInst *AI =
+ IRB.CreateAlloca(Ty, nullptr, Twine(Arg.getName()) + ".byval");
+ AI->setAlignment(Align);
----------------
Check what happens if the arg has no name. AFAIK it can be referenced as %0 (%1, etc) in the function body in that case, but getName() would return nullptr.
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:2557
+ uint64_t AllocSize = M->getDataLayout().getTypeAllocSize(Ty);
+ IRB.CreateMemCpy(AI, &Arg, AllocSize, Align);
+ }
----------------
Check what happens when byval argument has not explicit align attribute.
AFAIK, it must be handled this way:
unsigned ArgAlign = FArg.getParamAlignment();
if (ArgAlign == 0) {
Type *EltType = A->getType()->getPointerElementType();
ArgAlign = DL.getABITypeAlignment(EltType);
}
https://reviews.llvm.org/D34789
More information about the llvm-commits
mailing list