This is an archive of the discontinued LLVM Phabricator instance.

BuildLibCalls: infer allocptr attribute for free and realloc() family functions
ClosedPublic

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

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
Herald added a subscriber: hiraditya. · View Herald Transcript
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 420853.Apr 6 2022, 7:41 AM
durin42 edited the summary of this revision. (Show Details)
durin42 updated this revision to Diff 420914.Apr 6 2022, 9:10 AM
durin42 updated this revision to Diff 421207.Apr 7 2022, 7:36 AM
durin42 updated this revision to Diff 422242.Apr 12 2022, 8:33 AM
durin42 updated this revision to Diff 424968.Apr 25 2022, 10:55 AM
durin42 updated this revision to Diff 425067.Apr 25 2022, 5:15 PM
nikic added a subscriber: nikic.

Need to handle LibFunc___kmpc_free_shared as well?

Need to handle LibFunc___kmpc_free_shared as well?

No, for two reasons:

  1. The attributes can be specified directly on the declaration in llvm/Frontend/OpenMP/OMPKinds.def (see D119583)
  1. MemoryBuiltins.cpp never had any logic about __kmpc_free_shared: I can't tell if this was a bug or intentional, but what we have today matches the behavior of MemoryBuiltins.cpp.

We can do a follow-up later to add the required attributes in OMPKinds.def if you'd like.

Need to handle LibFunc___kmpc_free_shared as well?

No, for two reasons:

  1. The attributes can be specified directly on the declaration in llvm/Frontend/OpenMP/OMPKinds.def (see D119583)
  1. MemoryBuiltins.cpp never had any logic about __kmpc_free_shared: I can't tell if this was a bug or intentional, but what we have today matches the behavior of MemoryBuiltins.cpp.

The reason I asked is that this function is currently listed in https://github.com/llvm/llvm-project/blob/5ee0123642fee177258b0fd99f3fd659be68de60/llvm/lib/Analysis/MemoryBuiltins.cpp#L470. Is it non-functional for some reason?

Need to handle LibFunc___kmpc_free_shared as well?

No, for two reasons:

  1. The attributes can be specified directly on the declaration in llvm/Frontend/OpenMP/OMPKinds.def (see D119583)
  1. MemoryBuiltins.cpp never had any logic about __kmpc_free_shared: I can't tell if this was a bug or intentional, but what we have today matches the behavior of MemoryBuiltins.cpp.

The reason I asked is that this function is currently listed in https://github.com/llvm/llvm-project/blob/5ee0123642fee177258b0fd99f3fd659be68de60/llvm/lib/Analysis/MemoryBuiltins.cpp#L470. Is it non-functional for some reason?

Huh. I could have sworn that wasn't there, but I even edited it. Well, fixed by adding D124491 :)

nikic accepted this revision.Apr 27 2022, 12:30 AM

LGTM

This revision is now accepted and ready to land.Apr 27 2022, 12:30 AM

Missing description (some bigger context or RFC why you need this, future plans with it, etc)

durin42 updated this revision to Diff 425835.Apr 28 2022, 10:34 AM

@xbolva00 This is part of https://discourse.llvm.org/t/rfc-attributes-for-allocator-functions-in-llvm-ir/61464. @durin42 You might want to link to that in the description of this patch series.