IRGen: Marking inout parameter NoAlias at the LLVM level is not memory safe

We have to guarantee memory safety in the presence of the user violating the
inout assumption.  Claiming NoAlias for parameters that might alias is not
memory safe because LLVM will optimize based on that assumption.

Unfortunately, this means that llvm can't optimize arrays as aggressively. For
example, the load of array->buffer won't get hoisted out of loops (this is the
Sim2DArray regression below).

-O numbers (before/after):

CaptureProp 0.888365
Chars 1.09143
ImageProc 0.917197
InsertionSort 0.895204
JSONHelperDeserialize 0.909717
NSDictionaryCastToSwift 0.923466
Sim2DArray 0.76296
SwiftStructuresBubbleSort 0.897483

Continue emitting noalias for inout when compiling Ounchecked.

rdar://20041458

Swift SVN r25770
This commit is contained in:
Arnold Schwaighofer
2015-03-04 22:43:14 +00:00
parent 757ae5796e
commit edf4461ba3
31 changed files with 105 additions and 93 deletions

View File

@@ -810,6 +810,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
} else if (A->getOption().matches(OPT_Ounchecked)) {
// Turn on optimizations and remove all runtime checks.
IRGenOpts.Optimize = true;
IRGenOpts.Unchecked = true;
// Removal of cond_fail (overflow on binary operations).
Opts.RemoveRuntimeAsserts = true;
Opts.AssertConfig = SILOptions::Fast;