178 Commits

Author SHA1 Message Date
Alessandro Di Federico 35d2323fa0 SegregateStackAccesses: assert(findAssociatedCall) 2023-04-14 14:54:14 +02:00
Alessandro Di Federico be79842827 Enable DCE of revng_init_local_sp 2023-04-14 14:54:14 +02:00
Alessandro Di Federico b206957e5f DetectStackSizeAnalysis: fail if no Architecture 2023-04-14 14:54:14 +02:00
Alessandro Di Federico ccb660646e Introduce SimplifyCFGWithHoistAndSinkPass
This is a simple pass that enables running simplify-cfg with the legacy
pass manager enabling instruction hoisting and sinking.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 859a9ec2cf SegregateStackAccesses: do not iterate and modify
SegregateStackAccesses creates new functions. Iterating over existing
functions while creating new ones is problematic, so we now first
collect all the functions we want to inspect and then process them.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 5cfeb0fc36 InjectStackSizeProbesAtCallSitesPass: use nomerge
The `nomerge` attribute prevents this type of problematic deduplication
(specifically by simplify-cfg with sinking enabled) of calls to markers.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 82512ef81f CreateIntToPtr: adopt opaque pointer type 2023-04-14 14:54:14 +02:00
Alessandro Di Federico d33f339ec9 Adapt to revng.callerblock.start dismission
We no longer attach non-dbg metadata to instructions, it's not robust.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 7291314505 Stop using getPointer
After introduction of opaque pointers, it's not very effective.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 017aa6a47f Drop CallToLifted
We no longer have such tag, we now inspect the callee using
`isCallToIsolatedFunction`.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico ead746ba68 Adopt MemoryEffects
Switch from function attributes to MemoryEffects.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 887009a14b InaccessibleMemOnly: adopt MemoryEffects 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 21bbd8b414 Drop usages of Type::getPointerElementType 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 0e5863e2e4 Make CreateLoad usages opaque pointers-compatible 2023-04-14 14:54:14 +02:00
Alessandro Di Federico b0024a302f Fixes for SPTAR passed on the stack 2023-03-15 10:28:24 +01:00
Ivan Krysak 89774a1789 RemoveStackAlignmentPass: Add empty input support 2023-03-15 10:28:24 +01:00
Alessandro Di Federico d325e3b64a SSA: support shadow arguments on stack 2023-03-15 10:28:24 +01:00
Ivan Krysak c2f0fc19e5 ABI: FunctionType.h -> FunctionType/Layout.h 2023-03-15 10:28:24 +01:00
Alessandro Di Federico e73bd95493 Improve handling of declarations
SegregateStackAccesses and PromoteStackPointer were not handling
functions declarated (but not defined) properly.

This commit fixes this, in part by adopting `TaggedFunctionPass`.
2023-03-13 13:42:33 +01:00
Alessandro Di Federico f5a5990a30 Drop buildStringPtr in favor of getUniqueString 2023-03-13 13:42:33 +01:00
Alessandro Di Federico 098b9b3aa4 PromoteStackPointer: prevent DCE of init_local_sp
We need to prevent DCE from killing `revng_init_local_sp`, since certain
passes downstream might want to introduce new uses of it, and they might
be the first.

`SegregateStackAccesses` will take care of removing it by hand.
2023-02-21 16:48:35 +01:00
Pietro Fezzardi 97883844d3 Fix initialization of FunctionTags 2023-01-17 11:11:46 +01:00
Pietro Fezzardi 73507a8d26 SegregateStackAccessesPass: fix pusing calls ALAP
Before this commit, calls were marked to push ALAP in the wrong order,
resulting in preventing to actually push them ALAP.

This commit fixes the ordering, reactivating the code motion.
2022-12-24 03:01:48 +01:00
Massimo Fioravanti 87aef3fbad revng-c now uses Model accessors 2022-12-12 11:35:52 +01:00
Alessandro Di Federico 049b8657c3 Introduce RemoveStackAlignmentPass 2022-12-01 12:20:09 +01:00
Alessandro Di Federico 32e8333f58 PromoteStackPointer: handle CABIFunctionType 2022-12-01 12:20:09 +01:00
Alessandro Di Federico c5ab81cd08 Segregate: handle aggregate return values 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 3d6020139f Add type argument to 'revng_call_stack_arguments'
The additional argument is a pointer to a constant string that represent
the serialized model::QualifiedType of the argument.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 05c96a1a3a Adopt abi::FunctionType::ArgumentKind 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 28cb749573 Fix usage of revng_call_stack_arguments in calls
Before this commit, we did not take into consideration that
revng_call_stack_arguments has reference semantics, and we were using
its AddressOf in call sites that were taking the stack arguments.

This commit fixes the problem, bypassing the call to AddressOf when
passing the arguments to calls.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico f94ec452f4 SegregateStackAccesses: trunc stack arguments 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 23dd27b6b6 Ignore stack arguments, if stack size unknown
This commit handles the situation in which we have a call site with
stack arguments, but it was not possible to determine the stack height
at the call site.

The solution is to simply ignore stack arguments and emit in the IR a
warning.
2022-11-30 18:16:13 +01:00
Ivan Krysak 654afbef0c Move pointer creation away from model::Binary 2022-11-30 18:16:13 +01:00
Alessandro Di Federico bff488b79e SegregateStackAccessesPass.cpp: drop bogus comment 2022-11-30 18:16:13 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Massimo Fioravanti 5d730d1411 Upgrade to support starless revng 2022-10-20 16:06:13 +02:00
Alessandro Di Federico 74d912c01f Segregate: fix failure if nothing needs to be done
In case no model::Function needs to be acted upon, an assertion was
failing.
2022-09-01 15:10:02 +02:00
Massimo Fioravanti 370b081c0e Moved kinds to kinds namespace 2022-08-25 17:09:15 +02:00
Massimo Fioravanti 4abc358815 Add pipes required early outs on empty inputs 2022-08-09 12:26:01 +02:00
Pietro Fezzardi f8bc4a2e77 Move isCallToIsolatedFunction to FunctionTags.h 2022-08-09 08:02:10 +02:00
Antonio Frighetto 0ca87e8840 ModelHelpers: drop createEmptyStruct
`createEmptyStruct` has been upstreamed into revng.
2022-07-19 13:47:44 +02:00
Alvise de Faveri 221b8f74d9 Add reference semantics to stack opcodes
`revng_stack_frame` and `revng_stack_args` are treated as returning
a reference, and are always followed by an `AddressOf` call.
2022-06-28 10:23:45 +02:00
Alvise de Faveri e05972bd88 Make ref opcodes ReadOnly and InaccessibleMem
Add `ReadOnly` and `InaccessibleMemOnly` attributes to the following
functions:

- `revng_stack_frame`
- `revng_call_stack_arguments`
- `ModelGEP`
- `AddressOf`

This prevents `CSE` from grouping together any of these calls, while
still enabling `DCE` to remove calls that are not used.
2022-06-23 11:23:34 +02:00
Pietro Fezzardi d02f51c0f0 SegregateStackAccessesPass: handle dead code
Before this commit, SegregateStackAccessesPass always expected to find
calls stack_size_at_call_site markers injected by
InjectStackSizeProbesAtCallSitesPass.

This is not always true, because aggressive LLVM optimizations can
remove dead code.

As an example, if the user or some analysis earlier in the pipeline
wrongly marks registers as non-arguments, the optimization pipeline will
throw away and eliminate everything that descends from the initial
values of those registers.

This commit enables SegregateStackAccessesPass to cope with calls to
stack_size_at_call_site that were eliminated, and keep going just
considering the calls that are still there.
2022-05-31 12:40:52 +02:00
Pietro Fezzardi b09be7d34d SegregateStackAccesses: handle stackless Functions 2022-05-25 17:23:42 +02:00
Massimo Fioravanti b184360340 Make DetectStackSizePass into a pipeline analysis 2022-05-25 15:49:38 +02:00
Alessandro Di Federico f85f08e410 SegregateStackAccesses: handle CABIFunctionType
This commit heavily reworks SegregateStackAccesses in order to have
`llvm::Function`s reflect the prototype in the model.
2022-05-03 21:48:07 +02:00
Pietro Fezzardi fbe4f7520c Add SegregateStackAccessesPipe 2022-04-26 14:33:05 +02:00
Pietro Fezzardi 234f9cf401 Add PromoteStackPointerPipe 2022-04-26 14:21:59 +02:00
Alvise de Faveri 72461f6329 Add attributes to revng_init_local_sp() 2022-04-20 17:35:05 +02:00