avast / avast/retdec

llvmir2hll: Treat LLVM Intrinsic functions as Instruction-Idiom Functions

Open
#307 0 comments 0 reactions 1 assignee Claimed by @PeterMatula View on GitHub
C-bin2llvmir enhancement P-output
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Functions tagged as idiom functions in our config get the following comment in the output C (example for `fabsf`):
```cpp
// --------------- Instruction-Idiom Functions ----------------

// float32_t fabsf(float32_t a1);
```
It is often easier and cleaner to generate LLVM Intrinsic function, instead of an ordinary function that gets tagged with idiom flag - e.g. generate `@llvm.fabs.f32` without a flag, instead of `fabsf` with flag.
These LLVM Intrinsics are handled by llvmir2hll, but comments like the one above are not generated for the resulting functions. E.g. calls of `@llvm.fabs.f32` are generated to C as `fabsf`, but without the comment above.

Add the comment for all functions that are created from LLVM Intrinsics, regardless the tag in our config.

This is tested in `features.func-separation.IdiomFromFrontendTest`, which I disabled until this is fixed - `@llvm.fabs.f32` is generated in bin2llvmir instead of `fabsf` and the tested comment is no longer in the output C.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.