[llvm] [llvm][AArch64] Autoupgrade function attributes from Module attributes. (PR #80640)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 11:11:40 PST 2024


DanielKristofKiss wrote:

> Patch LGTM but I wanted to follow up on [the point about clang code gen](https://github.com/llvm/llvm-project/pull/80642#issuecomment-1942098974) from the other thread.
> 
> > > Also, I'm kind of surprised you didn't have to change anything in clang codegen of LLVM IR. Shouldn't clang now be generating fn attrs rather than module attrs?
> > > Clang can't really do much here as we add more functions to the module during later passes ( c++ exception handler, sanitisers especially). So the right thing is to derive the attributes from the module flag.
> 
> Right, I do recall issues with functions that have been synthesized by the compiler lacking certain function attributes...I thought we had another way of solving those (that was not AutoUpgrade). I think that's the point of `llvm::Function::createWithDefaultAttr`. Can you use that instead?

backend handles the model vs function attribute e.g. llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp::GetSignReturnAddress  

So far the module attribute is the contract between the fronted/backend and I know e.g. Rust relies on that too. 

Clang also just sets the module flags today if the flag is not function attribute, but I have a patch for that too but I need to add the `llvm::Function::createWithDefaultAttr` to it.

> > Autoupgrade now do this at the last moment before the functions merged into the common module.
> 
> Does auto upgrade run as a pass in the default pipelines? I thought it was just for helping folks move from one version of IR to another (for .bc or .ll files).

That is the change that I added here, [llvm/lib/Linker/IRMover.cpp](https://github.com/llvm/llvm-project/pull/80640/files#diff-4501da671276f6ba33e0701455975409a1f9f303c57a2e044a632e3d30a9947fR1609)
run the upgrade whenever 2 module got merged, so before we loose the module flags. 

https://github.com/llvm/llvm-project/pull/80640


More information about the llvm-commits mailing list