llvm-mirror/test/Transforms/Attributor
Arthur Eubanks ad84da6d6d Reland [X86] Codegen for preallocated
See https://reviews.llvm.org/D74651 for the preallocated IR constructs
and LangRef changes.

In X86TargetLowering::LowerCall(), if a call is preallocated, record
each argument's offset from the stack pointer and the total stack
adjustment. Associate the call Value with an integer index. Store the
info in X86MachineFunctionInfo with the integer index as the key.

This adds two new target independent ISDOpcodes and two new target
dependent Opcodes corresponding to @llvm.call.preallocated.{setup,arg}.

The setup ISelDAG node takes in a chain and outputs a chain and a
SrcValue of the preallocated call Value. It is lowered to a target
dependent node with the SrcValue replaced with the integer index key by
looking in X86MachineFunctionInfo. In
X86TargetLowering::EmitInstrWithCustomInserter() this is lowered to an
%esp adjustment, the exact amount determined by looking in
X86MachineFunctionInfo with the integer index key.

The arg ISelDAG node takes in a chain, a SrcValue of the preallocated
call Value, and the arg index int constant. It produces a chain and the
pointer fo the arg. It is lowered to a target dependent node with the
SrcValue replaced with the integer index key by looking in
X86MachineFunctionInfo. In
X86TargetLowering::EmitInstrWithCustomInserter() this is lowered to a
lea of the stack pointer plus an offset determined by looking in
X86MachineFunctionInfo with the integer index key.

Force any function containing a preallocated call to use the frame
pointer.

Does not yet handle a setup without a call, or a conditional call.
Does not yet handle musttail. That requires a LangRef change first.

Tried to look at all references to inalloca and see if they apply to
preallocated. I've made preallocated versions of tests testing inalloca
whenever possible and when they make sense (e.g. not alloca related,
inalloca edge cases).

Aside from the tests added here, I checked that this codegen produces
correct code for something like

```
struct A {
        A();
        A(A&&);
        ~A();
};

void bar() {
        foo(foo(foo(foo(foo(A(), 4), 5), 6), 7), 8);
}
```

by replacing the inalloca version of the .ll file with the appropriate
preallocated code. Running the executable produces the same results as
using the current inalloca implementation.

Reverted due to unexpectedly passing tests, added REQUIRES: asserts for reland.

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D77689
2020-05-20 11:25:44 -07:00
..
ArgumentPromotion AllocaInst should store Align instead of MaybeAlign. 2020-05-16 14:53:16 -07:00
IPConstantProp AllocaInst should store Align instead of MaybeAlign. 2020-05-16 14:53:16 -07:00
reduced [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
align.ll StoreInst should store Align, not MaybeAlign 2020-05-15 12:26:58 -07:00
alwaysinline.ll [Attributor] Force update of "newly live" abstract attributes 2020-05-11 15:32:47 -05:00
callbacks.ll [Attributor] Merge the query set into AbstractAttribute 2020-05-10 22:27:00 -05:00
dereferenceable-1.ll [Attributor] Check lines accidentally not committed with D76208 2020-05-13 18:24:05 -05:00
dereferenceable-2.ll StoreInst should store Align, not MaybeAlign 2020-05-15 12:26:58 -07:00
heap_to_stack.ll StoreInst should store Align, not MaybeAlign 2020-05-15 12:26:58 -07:00
internal-noalias.ll [Attributor] Improve the alignment of the loads 2020-05-13 18:24:05 -05:00
liveness_chains.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
liveness.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
lvi-after-jumpthreading.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
lvi-for-ashr.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
memory_locations.ll [Attributor][FIX] Carefully handle/ignore/forget argmemonly 2020-05-10 19:06:11 -05:00
misc_crash.ll [Attributor] Improve the alignment of the loads 2020-05-13 18:24:05 -05:00
misc.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
new_attributes.ll [Attributor][FIX] Record dependences for assumed dead abstract attributes 2020-05-07 17:00:50 -05:00
noalias.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
nocapture-1.ll [IR] Convert null-pointer-is-valid into an enum attribute 2020-05-15 19:41:07 +02:00
nocapture-2.ll StoreInst should store Align, not MaybeAlign 2020-05-15 12:26:58 -07:00
nofree.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
nonnull.ll [IR] Convert null-pointer-is-valid into an enum attribute 2020-05-15 19:41:07 +02:00
norecurse.ll [IR] Convert null-pointer-is-valid into an enum attribute 2020-05-15 19:41:07 +02:00
noreturn_async.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
noreturn_sync.ll [Attributor] Force update of "newly live" abstract attributes 2020-05-11 15:32:47 -05:00
noreturn.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
nosync.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
nounwind.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00
range.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
read_write_returned_arguments_scc.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
readattrs.ll [Attributor] Make AAIsDead dependences optional to prevent top state 2020-05-11 15:32:47 -05:00
returned.ll [Attributor][FIX] Stabilize the state of AAReturnedValues each update 2020-05-12 21:00:30 -05:00
undefined_behavior.ll [IR] Convert null-pointer-is-valid into an enum attribute 2020-05-15 19:41:07 +02:00
value-simplify.ll Reland [X86] Codegen for preallocated 2020-05-20 11:25:44 -07:00
willreturn.ll [Attributor] Use AAValueConstantRange to infer dereferencability. 2020-05-13 16:44:15 -05:00
wrapper.ll [Attributor][NFC] Remove obsolete option from tests 2020-04-21 15:22:10 -05:00