Commit Graph

146 Commits

Author SHA1 Message Date
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
Giacomo Vercesi ab125b35b0 Fix License headers
Change company name to "rev.ng Labs Srl" in all license headers
to reflect changed company name and legal status
Add missing license headers to files that didn't have one
2022-04-19 12:17:59 +02:00
Pietro Fezzardi 36541ae5cd QualifiedType RawFunctionType.StackArgumentsType 2022-04-08 17:58:06 +02:00
Antonio Frighetto 765219d58c Support for control-flow graph out of the model
The control-flow graph has been taken out of the model. Related changes
to `getCallSitePrototype` have been here addressed.
2022-04-06 16:25:05 +02:00
Alvise de Faveri 096ab1f5a1 Segregate: copy metadata on the new Call
Before this commit, SegregateStackAccessPass did not update properly the
metadata. Missing metadata did not allow the rest of the pipeline to
detect the special call.

This commit properly copies the metadata and updates the rest of the
pipeline to take care of the special call.
2022-03-22 11:48:27 +01:00
Alessandro Di Federico 1dcce82dfc Adopt cmake-format 2022-03-18 12:32:44 +01:00
Alessandro Di Federico 77335d036a Rename Lifted tag to Isolated 2022-03-17 14:08:05 +01:00
Alessandro Di Federico 5d197bff15 Adopt API changes in the model 2022-03-10 17:59:05 +01:00
Pietro Fezzardi 198ecd08d9 Update to new revng API for getCallSitePrototype
This commit updates the calls to getCallSitePrototype according to the
new API introduced in revng in commit 0659e6b6a3
2022-03-02 18:04:36 +01:00
Alessandro Di Federico 48fcca58ae DetectStackSize: limit stack arguments/frame size 2022-02-11 17:28:02 +01:00
Pietro Fezzardi d237bc439e IRCanonicalization: switch to FunctionTags 2022-01-14 14:29:05 +01:00
Pietro Fezzardi f2f783bf9d SegregateStackAccessPass: avoid 0-sized stacks 2022-01-11 09:46:21 +01:00
Alessandro Di Federico 7a910eeb48 PromoteStackPointer: ignore CABIFunctionType 2022-01-09 14:14:03 +01:00
Pietro Fezzardi 818156e06a DLA upgrades stack's and stack arguments' types 2022-01-04 16:21:07 +01:00
Alessandro Di Federico 904684e2f5 Prefix all libraries with "revngc" 2021-12-22 13:43:21 +01:00
Alessandro Di Federico 6fcf1673c9 Adopt eraseFromParent 2021-12-17 14:01:28 +01:00
Alessandro Di Federico 24f5515842 Import passes of the new stack promotion pipeline 2021-12-17 14:01:00 +01:00
Alessandro Di Federico d733640143 Ensure functions begin with allocas only
Mixin `alloca`s with other instructions is malpractice.
2021-12-17 13:50:46 +01:00
Alessandro Di Federico f51808be24 Review PromoteStackPointerPass
* Adjust stack pointer upon returning from call.
  In architecture where the return address is pushed on the stack, on
  the caller side, we see the the push but not the pop. This means that,
  once the stack pointer is no longer global, we need to take this into
  account.
  This commit fixes this increase the stack pointer of
  `FinalStackOffset` right after a function call.
* Drop the size argument from the `revng_init_local_sp` function.  We
  will have a `revng_stack_frame` function to represent the actual stack
  frame pointing to its beginning.
2021-12-17 13:50:46 +01:00
Alessandro Di Federico 01e4fb7f88 Minor changes to PromoteStackPointerPass 2021-12-17 13:50:46 +01:00
Alessandro Di Federico 54e9a96a03 PromoteStackPointer: do not force stack alignment 2021-12-17 13:50:46 +01:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Pietro Fezzardi 36e42855a5 PromoteStackPointer.cpp: fix deprecated include
This caused compilation error with llvm-12.
2021-05-27 17:14:25 +02:00
Pietro Fezzardi 36a525314a Detect isolated functions using FunctionTags 2021-04-27 21:19:06 +02:00
Pietro Fezzardi 52e29ccdbf PromoteStackPointer: do nothing with missing sp
The PromoteStackPointerPass now trivially handles running on modules
where the global variable for the stack pointer is missing.
When the global is not found, the pass just does nothing and returns
false.
This is necessary to handle very small functions, typically from tests.
2021-03-29 17:21:34 +02:00
Alessandro Di Federico 690e5fd9bd Update LoadModelPass usage 2021-03-16 12:01:15 +01:00
Pietro Fezzardi e95c21db25 Use Model to detect isolated functions 2021-02-23 10:39:05 +01:00
Pietro Fezzardi 148119c528 PromoteStackPointer: make local sp aligned 2021-02-09 15:07:04 +01:00
Pietro Fezzardi a31bdbd602 [DLA] Add PromoteStackPointerPass 2021-02-02 11:23:53 +01:00