summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
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
commit91db08bfe4a880dbb78e270e0f53d8aa30862ad2 (patch)
tree5679cdec1f235f5585399a79676a905ac22946f5 /llvm/lib/IR/Verifier.cpp
parent92fc0178c61db0fa9a9f52b4873fa366e47f658c (diff)
downloadbcm5719-llvm-91db08bfe4a880dbb78e270e0f53d8aa30862ad2.tar.gz
bcm5719-llvm-91db08bfe4a880dbb78e270e0f53d8aa30862ad2.zip
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 llvm-svn: 207676
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 43534385f38..1a8fb0a1f47 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud