diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-12-05 14:39:55 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-12-05 14:39:55 +0000 |
commit | 1e3b656be52e94c523d5fdb5a586a62ec59c3c51 (patch) | |
tree | 175995872d336c2e246de066c6d10149bf2800be /lib/Transforms/Instrumentation/MemorySanitizer.cpp | |
parent | 1b3fcf94a49fbbf0b1d0fb6086c3349c2092bd75 (diff) |
[msan] Instrument bswap intrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169383 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Instrumentation/MemorySanitizer.cpp')
-rw-r--r-- | lib/Transforms/Instrumentation/MemorySanitizer.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 183403d5fc..342751296b 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -1101,6 +1101,25 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { VAHelper->visitVACopyInst(I); } + void handleBswap(IntrinsicInst &I) { + IRBuilder<> IRB(&I); + Value *Op = I.getArgOperand(0); + Type *OpType = Op->getType(); + Function *BswapFunc = Intrinsic::getDeclaration( + F.getParent(), Intrinsic::bswap, ArrayRef<Type*>(&OpType, 1)); + setShadow(&I, IRB.CreateCall(BswapFunc, getShadow(Op))); + setOrigin(&I, getOrigin(Op)); + } + + void visitIntrinsicInst(IntrinsicInst &I) { + switch (I.getIntrinsicID()) { + case llvm::Intrinsic::bswap: + handleBswap(I); break; + default: + visitInstruction(I); break; + } + } + void visitCallSite(CallSite CS) { Instruction &I = *CS.getInstruction(); assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite"); @@ -1120,12 +1139,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { // will get propagated to a void RetVal. if (Call->isTailCall() && Call->getType() != Call->getParent()->getType()) Call->setTailCall(false); - if (isa<IntrinsicInst>(&I)) { - // All intrinsics we care about are handled in corresponding visit* - // methods. Add checks for the arguments, mark retval as clean. - visitInstruction(I); - return; - } + + assert(!isa<IntrinsicInst>(&I) && "intrinsics are handled elsewhere"); } IRBuilder<> IRB(&I); unsigned ArgOffset = 0; |