[PATCH] D159339: [urgent][CodeGen] First check the kind and then the llvm::Function properties.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 1 12:38:09 PDT 2023


v.g.vassilev added inline comments.


================
Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2389
   if (getTarget().getCXXABI().areMemberFunctionsAligned()) {
-    if (F->getPointerAlignment(getDataLayout()) < 2 && isa<CXXMethodDecl>(D))
+    if (isa<CXXMethodDecl>(D) && F->getPointerAlignment(getDataLayout()) < 2)
       F->setAlignment(std::max(llvm::Align(2), F->getAlign().valueOrOne()));
----------------
daltenty wrote:
> Thanks for looking into this. 
> 
> It's not clear to me how this re-ordering ends up fixing things. Can you clarify what the uninitialized value was in this expression?
> 
> 
The issue happens only in Release builds (RelWithDebInfo, too). From what I was able to see it is somewhere in `F->getPointerAlignment`. My assumption was that we cannot rely on the full properties of `F` to be set unless it is the declaration kind we expected (similar to checking if a something is a nullptr and then probing its members). Secondly the `isa` check is likely to be the less expensive check anyway.

I saw the issue yesterday and dug into it for a while. However, I decided to insert a "fix" before the release which is in few days since the `isa` seems to the faster check anyway.


Repository:
  rC Clang

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

https://reviews.llvm.org/D159339



More information about the cfe-commits mailing list