Add an isStrict flag to SIL pointer_to_address. (#3529)

Strict aliasing only applies to memory operations that use strict
addresses. The optimizer needs to be aware of this flag. Uses of raw
addresses should not have their address substituted with a strict
address.

Also add Builtin.LoadRaw which will be used by raw pointer loads.
This commit is contained in:
Andrew Trick
2016-07-15 15:04:02 -05:00
committed by GitHub
parent 5564f94867
commit c47687da2c
55 changed files with 366 additions and 207 deletions

View File

@@ -708,7 +708,8 @@ MaterializeForSetEmitter::emitUsingGetterSetter(SILGenFunction &gen,
// Set up the result buffer.
resultBuffer =
gen.B.createPointerToAddress(loc, resultBuffer,
RequirementStorageType.getAddressType());
RequirementStorageType.getAddressType(),
/*isStrict*/ true);
TemporaryInitialization init(resultBuffer, CleanupHandle::invalid());
// Evaluate the getter into the result buffer.
@@ -783,8 +784,8 @@ MaterializeForSetEmitter::createSetterCallback(SILFunction &F,
// The callback gets the value at +1.
auto &valueTL = gen.getTypeLowering(lvalue.getTypeOfRValue());
value = gen.B.createPointerToAddress(loc, value,
valueTL.getLoweredType().getAddressType());
value = gen.B.createPointerToAddress(
loc, value, valueTL.getLoweredType().getAddressType(), /*isStrict*/ true);
if (valueTL.isLoadable())
value = gen.B.createLoad(loc, value);
ManagedValue mValue = gen.emitManagedRValueWithCleanup(value, valueTL);