Skip to content

Add "optforfuzzing" func attribute when fuzzing is enabled#5080

Open
gnavdev28 wants to merge 2 commits intoldc-developers:masterfrom
gnavdev28:fix-fuzz-attr
Open

Add "optforfuzzing" func attribute when fuzzing is enabled#5080
gnavdev28 wants to merge 2 commits intoldc-developers:masterfrom
gnavdev28:fix-fuzz-attr

Conversation

@gnavdev28
Copy link

Description

This PR addresses issue #3172.
It ensures that the optforfuzzing LLVM attribute is added to functions when fuzzing is enabled. This behavior matches Clang's implementation and helps the LLVM optimizer work better for fuzzing targets.

Changes

  • gen/functions.cpp: Added a check to see if fuzzing is enabled and then applied the OptForFuzzing attribute to the function.

Verification

I have verified this change by checking the generated LLVM IR (.ll file). The attribute is now correctly added to the functions.

Evidence from LLVM IR:

; Function Attrs: optforfuzzing uwtable
define void @_Dmain() #0 {
...
attributes #0 = { optforfuzzing ... }

@JohanEngelen
Copy link
Member

lgtm, maybe add a testcase for it?

@gnavdev28
Copy link
Author

@JohanEngelen do I need to fix the error bot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants