diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-11-26 02:54:17 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-11-26 02:54:17 +0000 |
| commit | 8b291e66ebcd72e7e3970fac623924b1a6af4fbb (patch) | |
| tree | 11635727eab90d4de64e2c39301ae8d0b529259a /llvm/lib/VMCore | |
| parent | 3d14916b3e81d78ae02989904e8780d9a75da05a (diff) | |
| download | bcm5719-llvm-8b291e66ebcd72e7e3970fac623924b1a6af4fbb.tar.gz bcm5719-llvm-8b291e66ebcd72e7e3970fac623924b1a6af4fbb.zip | |
add a long-overdue AllocaInst::isStaticAlloca method.
llvm-svn: 60080
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 66caf5f9f0e..5b271d6a31c 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -732,6 +732,18 @@ AllocaInst::AllocaInst(const AllocaInst &AI) Instruction::Alloca, AI.getAlignment()) { } +/// isStaticAlloca - Return true if this alloca is in the entry block of the +/// function and is a constant size. If so, the code generator will fold it +/// into the prolog/epilog code, so it is basically free. +bool AllocaInst::isStaticAlloca() const { + // Must be constant size. + if (!isa<ConstantInt>(getArraySize())) return false; + + // Must be in the entry block. + const BasicBlock *Parent = getParent(); + return Parent == &Parent->getParent()->front(); +} + MallocInst::MallocInst(const MallocInst &MI) : AllocationInst(MI.getType()->getElementType(), (Value*)MI.getOperand(0), Instruction::Malloc, MI.getAlignment()) { |

