aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGValue.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-08-25 23:04:34 +0000
committerJohn McCall <rjmccall@apple.com>2011-08-25 23:04:34 +0000
commit410ffb2bc5f072d58a73c14560345bcf77dec1cc (patch)
tree162e003b95c3b8460288bdb6f6ee347e3ac61a77 /lib/CodeGen/CGValue.h
parent8c7e67d7644c3ab298bd6be724c9480da0979af6 (diff)
Track whether an AggValueSlot is potentially aliased, and do not
emit call results into potentially aliased slots. This allows us to properly mark indirect return slots as noalias, at the cost of requiring an extra memcpy when assigning an aggregate call result into a l-value. It also brings us into compliance with the x86-64 ABI. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138599 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGValue.h')
-rw-r--r--lib/CodeGen/CGValue.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/CodeGen/CGValue.h b/lib/CodeGen/CGValue.h
index dda9693f42..c448949d13 100644
--- a/lib/CodeGen/CGValue.h
+++ b/lib/CodeGen/CGValue.h
@@ -347,9 +347,14 @@ class AggValueSlot {
/// be set.
bool ZeroedFlag : 1;
+ /// AliasedFlag - This generally defaults to false, but can be true
+ /// if the memory is known not to be aliased.
+ bool AliasedFlag : 1;
+
public:
- enum IsZeroed_t { IsNotZeroed, IsZeroed };
+ enum IsAliased_t { IsNotAliased, IsAliased };
enum IsDestructed_t { IsNotDestructed, IsDestructed };
+ enum IsZeroed_t { IsNotZeroed, IsZeroed };
enum NeedsGCBarriers_t { DoesNotNeedGCBarriers, NeedsGCBarriers };
/// ignored - Returns an aggregate value slot indicating that the
@@ -358,7 +363,10 @@ public:
AggValueSlot AV;
AV.Addr = 0;
AV.Quals = Qualifiers();
- AV.LifetimeFlag = AV.RequiresGCollection = AV.ZeroedFlag = 0;
+ AV.LifetimeFlag = AV.RequiresGCollection = AV.ZeroedFlag = false;
+
+ // If there's ever an address here, it will be a temporary.
+ AV.AliasedFlag = false;
return AV;
}
@@ -375,6 +383,7 @@ public:
static AggValueSlot forAddr(llvm::Value *addr, Qualifiers quals,
IsDestructed_t isDestructed,
NeedsGCBarriers_t needsGC,
+ IsAliased_t isAliased = IsAliased,
IsZeroed_t isZeroed = IsNotZeroed) {
AggValueSlot AV;
AV.Addr = addr;
@@ -382,14 +391,16 @@ public:
AV.LifetimeFlag = isDestructed;
AV.RequiresGCollection = needsGC;
AV.ZeroedFlag = isZeroed;
+ AV.AliasedFlag = isAliased;
return AV;
}
static AggValueSlot forLValue(LValue LV, IsDestructed_t isDestructed,
NeedsGCBarriers_t needsGC,
+ IsAliased_t isAliased = IsAliased,
IsZeroed_t isZeroed = IsNotZeroed) {
return forAddr(LV.getAddress(), LV.getQuals(),
- isDestructed, needsGC, isZeroed);
+ isDestructed, needsGC, isAliased, isZeroed);
}
IsDestructed_t isLifetimeExternallyManaged() const {
@@ -421,6 +432,10 @@ public:
return Addr == 0;
}
+ IsAliased_t isPotentiallyAliased() const {
+ return IsAliased_t(AliasedFlag);
+ }
+
RValue asRValue() const {
return RValue::getAggregate(getAddr(), isVolatile());
}