summaryrefslogtreecommitdiff
path: root/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-01-16 22:59:24 +0000
committerReid Kleckner <reid@kleckner.net>2014-01-16 22:59:24 +0000
commitad60d3c304df0562f580b31aa91480aa854b0dfe (patch)
tree79dac0d501934c2fdd6eb414c4dc04131f444877 /lib/IR/Verifier.cpp
parent9b24eeee01a7e7225280ad90b44e06158cdb0806 (diff)
downloadllvm-ad60d3c304df0562f580b31aa91480aa854b0dfe.tar.gz
llvm-ad60d3c304df0562f580b31aa91480aa854b0dfe.tar.bz2
llvm-ad60d3c304df0562f580b31aa91480aa854b0dfe.tar.xz
Change inalloca rules to make it only apply to the last parameter
This makes things a lot easier, because we can now talk about the "argument allocation", which allocates all the memory for the call in one shot. The only functional change is to the verifier for a feature that hasn't shipped yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Verifier.cpp')
-rw-r--r--lib/IR/Verifier.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index d8e5c89598..002460e53d 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -910,6 +910,11 @@ void Verifier::VerifyFunctionAttrs(FunctionType *FT, AttributeSet Attrs,
if (Attrs.hasAttribute(Idx, Attribute::StructRet))
Assert1(Idx == 1, "Attribute sret is not on first parameter!", V);
+
+ if (Attrs.hasAttribute(Idx, Attribute::InAlloca)) {
+ Assert1(Idx == FT->getNumParams(),
+ "inalloca isn't on the last parameter!", V);
+ }
}
if (!Attrs.hasAttributes(AttributeSet::FunctionIndex))
@@ -1541,15 +1546,6 @@ void Verifier::VerifyCallSite(CallSite CS) {
// Verify call attributes.
VerifyFunctionAttrs(FTy, Attrs, I);
- // Verify that values used for inalloca parameters are in fact allocas.
- for (unsigned i = 0, e = CS.arg_size(); i != e; ++i) {
- if (!Attrs.hasAttribute(1 + i, Attribute::InAlloca))
- continue;
- Value *Arg = CS.getArgument(i);
- Assert2(isa<AllocaInst>(Arg), "Inalloca argument is not an alloca!", I,
- Arg);
- }
-
if (FTy->isVarArg()) {
// FIXME? is 'nest' even legal here?
bool SawNest = false;
@@ -1583,6 +1579,10 @@ void Verifier::VerifyCallSite(CallSite CS) {
Assert1(!Attrs.hasAttribute(Idx, Attribute::StructRet),
"Attribute 'sret' cannot be used for vararg call arguments!", I);
+
+ if (Attrs.hasAttribute(Idx, Attribute::InAlloca))
+ Assert1(Idx == CS.arg_size(), "inalloca isn't on the last argument!",
+ I);
}
}
@@ -1888,21 +1888,6 @@ void Verifier::visitAllocaInst(AllocaInst &AI) {
Assert1(AI.getArraySize()->getType()->isIntegerTy(),
"Alloca array size must have integer type", &AI);
- // Verify that an alloca instruction is not used with inalloca more than once.
- unsigned InAllocaUses = 0;
- for (User::use_iterator UI = AI.use_begin(), UE = AI.use_end(); UI != UE;
- ++UI) {
- CallSite CS(*UI);
- if (!CS)
- continue;
- unsigned ArgNo = CS.getArgumentNo(UI);
- if (CS.isInAllocaArgument(ArgNo)) {
- InAllocaUses++;
- Assert1(InAllocaUses <= 1,
- "Allocas can be used at most once with inalloca!", &AI);
- }
- }
-
visitInstruction(AI);
}