Commit Graph

810 Commits

Author SHA1 Message Date
Kacper Kołodziej bbebdd44b4 Prefer String.empty() case first 2023-04-04 09:30:09 +02:00
Kacper Kołodziej 17b0ecd78a Compare to nullptr instead of implicit cast
Prefer explicit comparing to nullptr instead of implicit casting pointer
to bool.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 8801fc3b33 Support empty strings in getUniqueString
This commit works around a quirk of
`llvm::ConstantDataArray::getString`, which returns a
`llvm::ConstantAggregateZero` for empty strings.

This quirk caused assertions in the previous implementation when passing
an empty `String` to `getUniqueString`.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 91af14007f Assert non-empty namespace in getUniqueString
Using an empty namespace causes the creation of a named metadata with an
empty string as name.
`llvm::verifyModule` does not check for that, so the `Module` still
verifies, but the on-disk serialization generated by `AsmPrinter.cpp`
prints `"empty name"` instead of the metadata name, and if the
serialized `Module` is then reparsed it parses succesfully but it does
not verify anymore.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi ec17b36801 Fix attributes of build_PlainMetaAddress function
These allow it to be DCE'd and CSE'd if possible directly by LLVM
instead of requiring us to handle it esplicitly as a special case.
2023-04-04 09:30:09 +02:00
Giacomo Vercesi f7c796553b ContainerSet: fix typo
Fix a typo in the code of ContainerSet.intersect that would lead to an
incorrect intersection.
2023-03-31 15:50:46 +02:00
Giacomo Vercesi 2e96e09f63 Drop analyze-all
Drop all the uses of analyzeAll and swap its use with the invocation of
the appropriate analysesList
2023-03-22 17:50:02 +01:00
Massimo Fioravanti 312e2e8d53 Add analyses lists
Introduces the possibility of specifiying lists of analyses as way to
give them coherent names.
2023-03-22 17:31:46 +01:00
Alessandro Di Federico b866e9010e ELFImporter: fix setting gp_mips canonical value
We used to set the canonical value of the MIPS gp register even in
absence of PLT, leading to a crash (specifically on archlinux librt.so).
2023-03-22 14:22:24 +01:00
Djordje Todorovic 956160e667 TypeCopier: Avoid copying the types twice 2023-03-22 11:38:12 +01:00
Giacomo Vercesi c7d13fd176 PipelineC: fix model verification clause
In the previous implementation of Model.verify an llvm::Error was
returned. Some call sites retained the logic associated with it. Fix
these with the correct logic.
Also fix an instance of `verify` that was missing an assert.
2023-03-20 16:20:06 +01:00
Giacomo Vercesi 3b94dfae4b PipelineC: rework rp_error data type
Drop the use of unique_ptr within the rp_error data type and instead use
std::monostate. Also fix the functions to allow the use of `nullptr` as
the error parameter
2023-03-20 16:08:04 +01:00
Alessandro Di Federico 92dd38c603 TypeCopier: copy PrimitiveTypes only when needed 2023-03-16 15:39:55 +01:00
Ivan Krysak 64856306c4 BinaryImporter: rework command line interface 2023-03-15 10:19:03 +01:00
Ivan Krysak 35956f46fe DwarfImporter: leave a note about static functions 2023-03-15 10:19:03 +01:00
Ivan Krysak 19e292f097 abi::FunctionType: standardize std integer usage
This reevaluates the places where `std::size_t` should be replaced by
`std::uint64_t` in the conversions, it also appends `std::` prefixes to
them where it's possible in preparation to the eventual `import std`
transition.
2023-03-15 10:19:03 +01:00
Ivan Krysak 7c360eb8d1 PDBImporter: preserve x64 vector and clr ABIs 2023-03-15 10:19:03 +01:00
Ivan Krysak 34b532c754 BinaryImporter: always promote original name 2023-03-15 10:19:03 +01:00
Ivan Krysak 08b3764b23 BinaryImporter: prevent overlap in segment struct 2023-03-15 10:19:03 +01:00
Ivan Krysak 1f27e938bf ABI: rework non-position based distribution
The original non-position based distribution (`considerRegisters`)
algorithm had a whole lot of problems preventing effective padding
support because it was written with only registers in mind.

As such, it was easier to rewrite the whole logic from scratch over
trying to fix it incrementally.
2023-03-15 10:19:03 +01:00
Ivan Krysak b8b1a716ed ABI: let NoOrDead painlessly decay to No 2023-03-15 10:19:03 +01:00
Ivan Krysak 2dfe65f65c ABI: purge unnamed types when analyses are done 2023-03-15 10:19:03 +01:00
Ivan Krysak 17c128c59b Make ABI depend on ModelPasses
Before now the dependency was the other way around
2023-03-15 10:19:03 +01:00
Ivan Krysak 4d21a88777 Model: remove an obsolete function conversion pass 2023-03-15 10:19:03 +01:00
Ivan Krysak 158272dee5 ABI: add an analysis for ToCABI conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak 952b938598 ABI: add an analysis for ToRaw conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak 3d05439001 ABI: improve multi-aligned stack argument support 2023-03-15 10:19:03 +01:00
Ivan Krysak 3edfaa827f ABI: preserve big scalar return values if possible 2023-03-15 10:19:03 +01:00
Ivan Krysak a936990c77 ABI: abstract stack alignment verification away 2023-03-15 10:19:03 +01:00
Ivan Krysak 806d4053a0 ABI: reintroduce conversion logs 2023-03-15 10:19:03 +01:00
Ivan Krysak 09f1d5b5e7 ABI: rework stack argument conversion 2023-03-15 10:19:03 +01:00
Ivan Krysak ea6148e616 DetectABI: leave a todo on droping RS deductions 2023-03-15 10:19:03 +01:00
Ivan Krysak a0adafeab0 ABI: take advantage of register state deductions
This makes the conversions more robust, since everything can rely on
the same tools for filling in missing registers and ordering them based
on the ABI requirements.
2023-03-15 10:19:03 +01:00
Ivan Krysak 0c82ff91b1 ABI: move the conversion ouside the helper class
This will allow reusing the helper class as the type manager.
2023-03-15 10:19:03 +01:00
Ivan Krysak 3422a9bf0f ABI: reintoduce conversion logs 2023-03-15 10:19:03 +01:00
Ivan Krysak b966637373 Layout: improve shadow return value handling
This brings the layout-side handling of these closer to the way they are
handled when converting the function.

The biggest change is the fact that now the return value location can
also be passed as the first stack argument.
2023-03-15 10:19:03 +01:00
Ivan Krysak a093d166b1 ABI: revamp basic floating point argument handling
This was a necessary change because without at least basic shortcuts
introduced here, we get a whole lot of failures downstream due to
layouts of such functions and the layout production is by design not
allowed to fail.
2023-03-15 10:19:03 +01:00
Ivan Krysak 9f7427c776 ABI: fix desynchronization of argument indices
When a shadow return value location argument is distributed, it is
shifting all the other argument indices by one. This was not taken into
the account previously. This commit fixes the indices.

It also makes it so the arguments `SizeOnStack` does not account for
padding. This is useful for some layout users.
2023-03-15 10:19:03 +01:00
Ivan Krysak f7be81737b ToRawConverter: don't attempt to recover types 2023-03-15 10:19:03 +01:00
Ivan Krysak 5bf13ac420 ABI: restructure ToRaw conversion root
This reorders the algorithms, so that the return values are handled
before the arguments. It also improves the wordind and extends
the comments annotating the function.

Moreover, it takes advantage of the `TypeBucket` to decouple type
management from the "raw" binary.
2023-03-15 10:19:02 +01:00
Ivan Krysak 4ecb88ab9d ABI: move ToCABIConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 51beb8fc1b ABI: move ToRawConverter onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 59d3b627a1 ABI: simplify default prototype stack traces 2023-03-15 10:19:02 +01:00
Ivan Krysak 039de1fe6d ABI: move function prototype onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 9e393578c9 ABI: move state deduction onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak b19572ea67 Model: Leave a note about the alignment 2023-03-15 10:19:02 +01:00
Ivan Krysak 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 769e5c1cbe ABI: add a natural alignment calculation helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 8b675e131e ABI: introduce runtime abi definition 2023-03-15 10:19:02 +01:00
Ivan Krysak 87bded80d3 ABI: rename RegisterList into RegisterVector 2023-03-15 10:19:02 +01:00