[PATCH] D99592: [PoC][Clang] Use TypeSize instead of uint64_t for getTypeAllocSize().

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 30 13:35:50 PDT 2021


sdesmalen added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2856
         Address AddrToStoreInto = Address::invalid();
-        if (SrcSize <= DstSize) {
+        if (llvm::TypeSize::isKnownLE(SrcSize, DstSize)) {
           AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy);
----------------
Can we assume their scalable flags must match? In that case, it's best to assert this.

`llvm::TypeSize::isKnownLE()` should be used with some caution, because `isKnownLE(4, vscale x 4)` evaluates to true, so if their scalable flags don't match, this may lead to surprising results.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:4929
                                Src.getName() + ".coerce");
-          Builder.CreateMemCpy(TempAlloca, Src, SrcSize);
+          Builder.CreateMemCpy(TempAlloca, Src, SrcSize.getKnownMinSize());
           Src = TempAlloca;
----------------
This doesn't seem correct for scalable vectors.
If you expect it to work only for fixed-width vectors, you should use `getFixedSize` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99592



More information about the llvm-commits mailing list