[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 24 03:29:02 PDT 2021


xbolva00 added a comment.

In D100879#2714431 <https://reviews.llvm.org/D100879#2714431>, @dmgreen wrote:

> Hello. Nice idea. Unfortunately this blocks tail folding, making codesize a bit bigger: https://godbolt.org/z/rncPvbh8d
> I'm guessing it shouldn't? But the attribute isn't handled somewhere along the way. Any ideas where?



In D100879#2714431 <https://reviews.llvm.org/D100879#2714431>, @dmgreen wrote:

> Hello. Nice idea. Unfortunately this blocks tail folding, making codesize a bit bigger: https://godbolt.org/z/rncPvbh8d
> I'm guessing it shouldn't? But the attribute isn't handled somewhere along the way. Any ideas where?

Hmm.. I know I think.

  diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
  index 5d1b00463dc8..425e1b4e8e2d 100644
  --- a/llvm/lib/CodeGen/Analysis.cpp
  +++ b/llvm/lib/CodeGen/Analysis.cpp
  @@ -560,6 +560,8 @@ bool llvm::attributesPermitTailCall(const Function *F, const Instruction *I,
   
     // Following attributes are completely benign as far as calling convention
     // goes, they shouldn't affect whether the call is a tail call.
  +  CallerAttrs.removeAttribute(Attribute::Alignment);
  +  CalleeAttrs.removeAttribute(Attribute::Alignment);
     CallerAttrs.removeAttribute(Attribute::NoAlias);
     CalleeAttrs.removeAttribute(Attribute::NoAlias);
     CallerAttrs.removeAttribute(Attribute::NonNull);

Inspiration: https://github.com/llvm/llvm-project/commit/62ad2128255877ed41c714366861eee9c1da30dd

If you want you can fix it (or I can do that later today).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100879



More information about the cfe-commits mailing list