vast icon indicating copy to clipboard operation
vast copied to clipboard

Refactor attribute builders from codegen to AttrVisitor

Open xlauko opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] I have read the documentation and the proposed feature is not implemented.

Description

At the moment vast operations create attributes, however since we have AttrVisitor, we duplicate logic for attribute creation. We should extract all translations of clang::Attributes to be performed only via AttrVisitor. At the moment, this is probably only GlobalLinkageKindAttr.

xlauko avatar Oct 17 '23 08:10 xlauko

Minimal example

#define weak __attribute__((__weak__))

extern "C" {
  weak void init();
}

int main() {
    init();
}

vast-front produces

 "hl.func"() ({
  }) {function_type = !core.fn<() -> (!hl.void)>, linkage = 4 : i32, sym_name = "_fini", sym_visibility = "private", weak = #unsup<attr "weak">} : () -> ()

we want to have only linkage attr and omit weak = #unsup<attr "weak">

xlauko avatar Oct 17 '23 08:10 xlauko

The duplicit attributes were resolved as part of #411 but the logic wasn't moved to AttrVisitor as linkage requires more information than we can access through an attribute. I'll mark it as backlog for the case we want to revisit this in the future.

Jezurko avatar Oct 24 '23 14:10 Jezurko