summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/StackProtector.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-01-20 19:49:14 +0000
committerHal Finkel <hfinkel@anl.gov>2014-01-20 19:49:14 +0000
commita69e5b8b9d32801ed0db5fe2c112a9f81808ddee (patch)
treea534433ea92092b71645be9f09565cc34998e77d /llvm/lib/CodeGen/StackProtector.cpp
parent450d1661be35e65ad77c0d45613e19e7a5d4b2f1 (diff)
downloadbcm5719-llvm-a69e5b8b9d32801ed0db5fe2c112a9f81808ddee.tar.gz
bcm5719-llvm-a69e5b8b9d32801ed0db5fe2c112a9f81808ddee.zip
Update StackProtector when coloring merges stack slots
StackProtector keeps a ValueMap of alloca instructions to layout kind tags for use by PEI and other later passes. When stack coloring replaces one alloca with a bitcast to another one, the key replacement in this map does not work. Instead, provide an interface to manage this updating directly. This seems like an improvement over the old behavior, where the layout map would not get updated at all when the stack slots were merged. In practice, however, there is likely no observable difference because PEI only did anything special with 'large array' kinds, and if one large array is merged with another, than the replacement should already have been a large array. This is an attempt to unbreak the clang-x86_64-darwin11-RA builder. llvm-svn: 199684
Diffstat (limited to 'llvm/lib/CodeGen/StackProtector.cpp')
-rw-r--r--llvm/lib/CodeGen/StackProtector.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index b350237f9b6..f2925ef7712 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -57,6 +57,27 @@ StackProtector::getSSPLayout(const AllocaInst *AI) const {
return AI ? Layout.lookup(AI) : SSPLK_None;
}
+void StackProtector::adjustForColoring(const AllocaInst *From,
+ const AllocaInst *To) {
+ // When coloring replaces one alloca with another, transfer the SSPLayoutKind
+ // tag from the remapped to the target alloca. The remapped alloca should
+ // have a size smaller than or equal to the replacement alloca.
+ SSPLayoutMap::iterator I = Layout.find(From);
+ if (I != Layout.end()) {
+ SSPLayoutKind Kind = I->second;
+ Layout.erase(I);
+
+ // Transfer the tag, but make sure that SSPLK_AddrOf does not overwrite
+ // SSPLK_SmallArray or SSPLK_LargeArray, and make sure that
+ // SSPLK_SmallArray does not overwrite SSPLK_LargeArray.
+ I = Layout.find(To);
+ if (I == Layout.end())
+ Layout.insert(std::make_pair(To, Kind));
+ else if (I->second != SSPLK_LargeArray && Kind != SSPLK_AddrOf)
+ I->second = Kind;
+ }
+}
+
bool StackProtector::runOnFunction(Function &Fn) {
F = &Fn;
M = F->getParent();
OpenPOWER on IntegriCloud