summaryrefslogtreecommitdiff
path: root/lib/Analysis/Lint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/Lint.cpp')
-rw-r--r--lib/Analysis/Lint.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp
index ada600a69b87..7b792ed0a2e2 100644
--- a/lib/Analysis/Lint.cpp
+++ b/lib/Analysis/Lint.cpp
@@ -285,15 +285,24 @@ void Lint::visitCallSite(CallSite CS) {
}
}
- if (CS.isCall() && cast<CallInst>(CS.getInstruction())->isTailCall())
- for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
- AI != AE; ++AI) {
- Value *Obj = findValue(*AI, /*OffsetOk=*/true);
- Assert(!isa<AllocaInst>(Obj),
- "Undefined behavior: Call with \"tail\" keyword references "
- "alloca",
- &I);
+ if (CS.isCall()) {
+ const CallInst *CI = cast<CallInst>(CS.getInstruction());
+ if (CI->isTailCall()) {
+ const AttributeList &PAL = CI->getAttributes();
+ unsigned ArgNo = 0;
+ for (Value *Arg : CS.args()) {
+ // Skip ByVal arguments since they will be memcpy'd to the callee's
+ // stack anyway.
+ if (PAL.hasParamAttribute(ArgNo++, Attribute::ByVal))
+ continue;
+ Value *Obj = findValue(Arg, /*OffsetOk=*/true);
+ Assert(!isa<AllocaInst>(Obj),
+ "Undefined behavior: Call with \"tail\" keyword references "
+ "alloca",
+ &I);
+ }
}
+ }
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I))
@@ -683,7 +692,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
if (Instruction::isCast(CE->getOpcode())) {
if (CastInst::isNoopCast(Instruction::CastOps(CE->getOpcode()),
CE->getOperand(0)->getType(), CE->getType(),
- DL->getIntPtrType(V->getType())))
+ *DL))
return findValueImpl(CE->getOperand(0), OffsetOk, Visited);
} else if (CE->getOpcode() == Instruction::ExtractValue) {
ArrayRef<unsigned> Indices = CE->getIndices();