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

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 13:19:45 PST 2022


yota9 accepted this revision.
yota9 added inline comments.


================
Comment at: bolt/unittests/Core/MCPlusBuilder.cpp:113
+TEST_P(MCPlusBuilderTester, Annotation) {
+  if (GetParam() != Triple::x86_64)
+    GTEST_SKIP();
----------------
Amir wrote:
> 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
Oh yes, I forgot about that, thanks.


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