diff options
author | John McCall <rjmccall@apple.com> | 2011-08-25 23:04:34 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-08-25 23:04:34 +0000 |
commit | a5efa7386ad9920e969ba4f155de3b40f8118cae (patch) | |
tree | cfa90d732233b92aab897950fdd571c28cf9dbaa /clang/lib/CodeGen/CGValue.h | |
parent | 5cc730cdef97d98df0b33a21a6b9568b9cddccb1 (diff) | |
download | bcm5719-llvm-a5efa7386ad9920e969ba4f155de3b40f8118cae.tar.gz bcm5719-llvm-a5efa7386ad9920e969ba4f155de3b40f8118cae.zip |
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.
llvm-svn: 138599
Diffstat (limited to 'clang/lib/CodeGen/CGValue.h')
-rw-r--r-- | clang/lib/CodeGen/CGValue.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index dda9693f42c..c448949d134 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/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()); } |