summaryrefslogtreecommitdiff
path: root/lib/IR
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-01-17 23:58:17 +0000
committerReid Kleckner <reid@kleckner.net>2014-01-17 23:58:17 +0000
commit3cbfa1617f0d935d68bf519afb5720df066849c2 (patch)
treebbd9321083451c055f56f050fe08c56d5a35d9f6 /lib/IR
parent01d9f5972a0d7b0d88f815e6f7424f5f7b5bdb04 (diff)
downloadllvm-3cbfa1617f0d935d68bf519afb5720df066849c2.tar.gz
llvm-3cbfa1617f0d935d68bf519afb5720df066849c2.tar.bz2
llvm-3cbfa1617f0d935d68bf519afb5720df066849c2.tar.xz
Add an inalloca flag to allocas
Summary: The only current use of this flag is to mark the alloca as dynamic, even if its in the entry block. The stack adjustment for the alloca can never be folded into the prologue because the call may clear it and it has to be allocated at the top of the stack. Reviewers: majnemer CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2571 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199525 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r--lib/IR/Function.cpp7
-rw-r--r--lib/IR/Instructions.cpp5
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index bb6bef7bd0..c1fa3720e3 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -92,6 +92,13 @@ bool Argument::hasInAllocaAttr() const {
hasAttribute(getArgNo()+1, Attribute::InAlloca);
}
+bool Argument::hasByValOrInAllocaAttr() const {
+ if (!getType()->isPointerTy()) return false;
+ AttributeSet Attrs = getParent()->getAttributes();
+ return Attrs.hasAttribute(getArgNo() + 1, Attribute::ByVal) ||
+ Attrs.hasAttribute(getArgNo() + 1, Attribute::InAlloca);
+}
+
unsigned Argument::getParamAlignment() const {
assert(getType()->isPointerTy() && "Only pointers have alignments");
return getParent()->getParamAlignment(getArgNo()+1);
diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp
index 761f60063f..5a50b73650 100644
--- a/lib/IR/Instructions.cpp
+++ b/lib/IR/Instructions.cpp
@@ -893,7 +893,8 @@ void AllocaInst::setAlignment(unsigned Align) {
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
assert(Align <= MaximumAlignment &&
"Alignment is greater than MaximumAlignment!");
- setInstructionSubclassData(Log2_32(Align) + 1);
+ setInstructionSubclassData((getSubclassDataFromInstruction() & ~31) |
+ (Log2_32(Align) + 1));
assert(getAlignment() == Align && "Alignment representation error!");
}
@@ -916,7 +917,7 @@ bool AllocaInst::isStaticAlloca() const {
// Must be in the entry block.
const BasicBlock *Parent = getParent();
- return Parent == &Parent->getParent()->front();
+ return Parent == &Parent->getParent()->front() && !isUsedWithInAlloca();
}
//===----------------------------------------------------------------------===//