This is an archive of the discontinued LLVM Phabricator instance.

Emit annotate attributes for function declarations
AbandonedPublic

Authored by jobnoorman on Jul 16 2013, 2:02 AM.

Details

Reviewers
rjmccall
Summary

This patch makes sure annotation attributes are emitted for declarations. It does this by applying two changes.

First, AddGlobalAnnotations is called from SetFunctionAttributes instead of from EmitGlobalFunctionDefinition. This makes sure these annotations are emitted for declarations but makes code like the following crash:

__attribute__((annotate("foo"))) void foo();
void bar(){foo();}
void foo() {}

I will try to explain what I think happens when this code is compiled:

  1. A declaration is created for a function foo having an unspecified number of arguments. This declaration is not emitted but queued for deferred emission. My patch did create an annotation referring to this declaration, though.
  2. The call site triggers emission of the declaration of foo.
  3. Now foo has zero arguments and the original declaration is replaced by a new function. Since the added annotation still refers to the deleted declaration, this causes a crash.

Therefore, my patch also changes AddGlobalAnnotations to not create the annotation right away. Instead, annotations are created in EmitGlobalAnnotations.

Diff Detail

Event Timeline

jobnoorman edited edge metadata.

This is the same patch but based on current trunk.

jobnoorman abandoned this revision.Feb 8 2023, 2:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2023, 2:25 AM
Herald added a subscriber: pmatos. · View Herald Transcript