[PATCH] D146164: Fix nomerge attribute not working with __builtin_trap().

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 12:07:02 PDT 2023


rsmith added a comment.

FYI: this attribute appears to not work on (at least) x86 and arm currently, because the backend also does some merging: https://godbolt.org/z/d43M83oax



================
Comment at: clang/lib/CodeGen/CGExpr.cpp:3626-3627
   }
-
+  if (InNoMergeAttributedStmt)
+    TrapCall->addFnAttr(llvm::Attribute::NoMerge);
   return TrapCall;
----------------
There are 496 calls to `Builder.CreateCall` in clang's `CodeGen`. Do they all need this change? If not, how can we be confident we've found all the ones that do? (From a quick check, at least MSVC's `__fastfail` builtin seems like it would also benefit from this handling.)

Would it be reasonable to make clang's `CGBuilder` do this for every call instruction we create?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146164



More information about the cfe-commits mailing list