[PATCH] D150803: [WebAssembly] Support `annotate` clang attributes for marking functions.

Sam Clegg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 27 15:53:37 PDT 2023


sbc100 added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp:585-598
+    // The fifth field is an optional pointer to the arguments. Append each
+    // argument to the name separated by a '.'.
+    auto *ArgsVar = dyn_cast<GlobalVariable>(CS->getOperand(4)->stripPointerCasts());
+    if (ArgsVar) {
+      auto *ArgsStruct = cast<ConstantStruct>(ArgsVar->getInitializer());
+      for (Value *ArgOp : ArgsStruct->operands()) {
+        StringRef Arg;
----------------
brendandahl wrote:
> This currently supports arguments, but it's somewhat brittle since the arguments aren't escaped. I'm fine with dropping this and only supporting name, but I think this could be useful.
I'd suggest going for the simplified version.. and just ignore any annotations that have arguments.   My rational here is that we shouldn't add stuff that we don't actually need yet, and also that the code annotation proposal might supersede this mechanism in the future.  



================
Comment at: llvm/test/MC/WebAssembly/func-attr.s:21
+# CHECK-OBJ-NEXT:          Offset:          0x0
+# CHECK-OBJ-NEXT:     Name:            func_attr.custom0
----------------
Should these be `llvm.func_attr.custom0` perhaps?

I also wonder if its makes sense to preserve all of these.  I worry that it could result in production code that contains these extra sections.   Can we figure out way to drop them by default on only preserve them in the cases we care about?

How about maybe a linker flag?  Something like `--preserve-attributes=async`.. that emcc could inject?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150803/new/

https://reviews.llvm.org/D150803



More information about the cfe-commits mailing list