[PATCH] D120260: [BOLT][NFC] Fix undefined behavior in encodeAnnotationImm

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 13:16:47 PST 2022


Amir added inline comments.


================
Comment at: bolt/unittests/Core/MCPlusBuilder.cpp:113
+TEST_P(MCPlusBuilderTester, Annotation) {
+  if (GetParam() != Triple::x86_64)
+    GTEST_SKIP();
----------------
yota9 wrote:
> Amir wrote:
> > maksfb wrote:
> > > Any reason for x86_64-only?
> > `createCall` is not defined in AArch64MCPlusBuilder
> Sorry, but why not just use BC->MIB->addAnnotation directly? 
There's no way to put a predefined Value into an encoded annotation immediate using addAnnotation.
addAnnotation allocates a `MCSimpleAnnotation<ValueType>` using placement new, and passes the pointer to allocated object to
setAnnotationOpValue.

https://github.com/llvm/llvm-project/blob/main/bolt/include/bolt/Core/MCPlusBuilder.h#L1639


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120260



More information about the llvm-commits mailing list