This is an archive of the discontinued LLVM Phabricator instance.

Attributes: add a new `allocptr` attribute
ClosedPublic

Authored by durin42 on Apr 4 2022, 3:17 PM.

Details

Summary

This continues the push away from hard-coded knowledge about functions
towards attributes. We'll use this to annotate free(), realloc() and
cousins and obviate the hard-coded list of free functions.

Diff Detail

Event Timeline

durin42 created this revision.Apr 4 2022, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2022, 3:17 PM
durin42 requested review of this revision.Apr 4 2022, 3:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2022, 3:17 PM
durin42 updated this revision to Diff 420852.Apr 6 2022, 7:41 AM
durin42 edited the summary of this revision. (Show Details)
durin42 updated this revision to Diff 420913.Apr 6 2022, 9:10 AM
durin42 updated this revision to Diff 421206.Apr 7 2022, 7:36 AM
durin42 updated this revision to Diff 422241.Apr 12 2022, 8:33 AM
durin42 updated this revision to Diff 424967.Apr 25 2022, 10:55 AM
durin42 updated this revision to Diff 425066.Apr 25 2022, 5:15 PM
nikic accepted this revision.Apr 26 2022, 12:49 AM
nikic added a subscriber: nikic.

LG

llvm/include/llvm/IR/Attributes.td
54

manipulated

llvm/lib/IR/Attributes.cpp
1807

Possibly, but I think it's okay to keep it here -- being safe to drop is mainly important if the attribute can be inferred, while this one has to be placed by the frontend.

This revision is now accepted and ready to land.Apr 26 2022, 12:49 AM
nikic added a comment.Apr 26 2022, 2:22 AM

By the way, in which revision is this actually used? Do you plan to change the isRealloc/isFree APIs to check a specific operand of the call, rather than just the call?

By the way, in which revision is this actually used? Do you plan to change the isRealloc/isFree APIs to check a specific operand of the call, rather than just the call?

Yeah, eventually the (remaining) callers of isFree need to check for the annotated operand rather than just blindly grabbing the first one (as an example). Mercifully all free/realloc functions today are similar-enough that the hard coded argument number works today, but this is futureproofing to make sure everything continues to work.

This revision was landed with ongoing or failed builds.Apr 26 2022, 10:57 AM
This revision was automatically updated to reflect the committed changes.