summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-04-30 17:22:00 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-04-30 17:22:00 +0000
commitbf741d2bddfa75babd032db3039064746a8f86ba (patch)
tree831189a8b03c0ecf94afaec8763e9abd3bc5192a /lib
parent1c37cbdf5490ac4d649a372e1b7ce939521b038e (diff)
downloadllvm-bf741d2bddfa75babd032db3039064746a8f86ba.tar.gz
llvm-bf741d2bddfa75babd032db3039064746a8f86ba.tar.bz2
llvm-bf741d2bddfa75babd032db3039064746a8f86ba.tar.xz
IR: Conservatively verify inalloca arguments
Summary: Try to spot obvious mismatches with inalloca use. Reviewers: rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D3572 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/IR/Verifier.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 43534385f3..1a8fb0a1f4 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -1494,6 +1494,16 @@ void Verifier::VerifyCallSite(CallSite CS) {
// Verify call attributes.
VerifyFunctionAttrs(FTy, Attrs, I);
+ // Conservatively check the inalloca argument.
+ // We have a bug if we can find that there is an underlying alloca without
+ // inalloca.
+ if (CS.hasInAllocaArgument()) {
+ Value *InAllocaArg = CS.getArgument(FTy->getNumParams() - 1);
+ if (auto AI = dyn_cast<AllocaInst>(InAllocaArg->stripInBoundsOffsets()))
+ Assert2(AI->isUsedWithInAlloca(),
+ "inalloca argument for call has mismatched alloca", AI, I);
+ }
+
if (FTy->isVarArg()) {
// FIXME? is 'nest' even legal here?
bool SawNest = false;