Andrew Kelley via llvm-dev
2017-Oct-23 20:02 UTC
[llvm-dev] maximum value for alignstack function attribute?
I have this test case in my frontend, which is triggering an assert in llvm master branch: fn fnWithAlignedStack() -> i32 { @setAlignStack(1024); return 1234; } It sets alignstack=1024 in the function attributes (see http://llvm.org/docs/LangRef.html#function-attributes). It's tripping an assert: llvm/lib/IR/Attributes.cpp:134: static llvm::Attribute llvm::Attribute::getWithStackAlignment(llvm::LLVMContext&, uint64_t): Assertion `Align <= 0x100 && "Alignment too large."' Is 0x100 the correct maximum alignstack value? Can I submit a patch to document this in LangRef.html? Regards, Andrew Kelley -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171023/9a61cd7d/attachment.html>
Friedman, Eli via llvm-dev
2017-Oct-23 21:59 UTC
[llvm-dev] maximum value for alignstack function attribute?
On 10/23/2017 1:02 PM, Andrew Kelley via llvm-dev wrote:> I have this test case in my frontend, which is triggering an assert in > llvm master branch: > > fn fnWithAlignedStack() -> i32 { > @setAlignStack(1024); > return 1234; > } > > It sets alignstack=1024 in the function attributes (see > http://llvm.org/docs/LangRef.html#function-attributes). It's tripping > an assert: > > llvm/lib/IR/Attributes.cpp:134: static llvm::Attribute > llvm::Attribute::getWithStackAlignment(llvm::LLVMContext&, uint64_t): > Assertion `Align <= 0x100 && "Alignment too large."' > > Is 0x100 the correct maximum alignstack value? Can I submit a patch to > document this in LangRef.html?Yes...? But nobody should ever specify a value anywhere near that large. The point of the attribute is to fixup the stack alignment in cases of ABI mismatches, so you normally don't want to specify a value higher than the actual ABI alignment of the stack. If you want to allocate aligned memory on the stack, you can just set the alignment of an alloca, and the code generator will provide memory with the appropriate alignment. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Ben Craig via llvm-dev
2017-Oct-23 22:04 UTC
[llvm-dev] maximum value for alignstack function attribute?
There could be performance benefits to aligning to larger sizes. Some memory controllers really like it when you start at a page boundary for example.> -----Original Message----- > From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of > Friedman, Eli via llvm-dev > Sent: Monday, October 23, 2017 4:59 PM > To: Andrew Kelley <superjoe30 at gmail.com>; LLVM Dev <llvm- > dev at lists.llvm.org> > Subject: Re: [llvm-dev] maximum value for alignstack function attribute? > > On 10/23/2017 1:02 PM, Andrew Kelley via llvm-dev wrote: > > I have this test case in my frontend, which is triggering an assert in > > llvm master branch: > > > > fn fnWithAlignedStack() -> i32 { > > @setAlignStack(1024); > > return 1234; > > } > > > > It sets alignstack=1024 in the function attributes (see > > https://urldefense.proofpoint.com/v2/url?u=http- > 3A__llvm.org_docs_Lang > > Ref.html-23function- > 2Dattributes&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA > &r=y8mub81SfUi- > UCZRX0Vl1g&m=0DdfVtZNBtfRLf7sV4nDkOZcRe2iDuboLEtD2AwEtAA&s=Tfr > Mg902OEsdzbClQaj1_afFH3xp9lwmeSNyJELBGCw&e=). It's tripping an > assert: > > > > llvm/lib/IR/Attributes.cpp:134: static llvm::Attribute > > llvm::Attribute::getWithStackAlignment(llvm::LLVMContext&, uint64_t): > > Assertion `Align <= 0x100 && "Alignment too large."' > > > > Is 0x100 the correct maximum alignstack value? Can I submit a patch to > > document this in LangRef.html? > > Yes...? But nobody should ever specify a value anywhere near that large. > > The point of the attribute is to fixup the stack alignment in cases of ABI > mismatches, so you normally don't want to specify a value higher than the > actual ABI alignment of the stack. If you want to allocate aligned memory on > the stack, you can just set the alignment of an alloca, and the code generator > will provide memory with the appropriate alignment. > > -Eli > > -- > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a > Linux Foundation Collaborative Project > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi- > 2Dbin_mailman_listinfo_llvm- > 2Ddev&d=DwIGaQ&c=I_0YwoKy7z5LMTVdyO6YCiE2uzI1jjZZuIPelcSjixA&r=y8 > mub81SfUi- > UCZRX0Vl1g&m=0DdfVtZNBtfRLf7sV4nDkOZcRe2iDuboLEtD2AwEtAA&s=DbZ > yApdztiMbDVGsqQdh1u4geFYbVbGnXhK20e2seq8&e=
Andrew Kelley via llvm-dev
2017-Oct-23 22:09 UTC
[llvm-dev] maximum value for alignstack function attribute?
On Mon, Oct 23, 2017 at 5:59 PM, Friedman, Eli <efriedma at codeaurora.org> wrote:> On 10/23/2017 1:02 PM, Andrew Kelley via llvm-dev wrote: > >> I have this test case in my frontend, which is triggering an assert in >> llvm master branch: >> >> fn fnWithAlignedStack() -> i32 { >> @setAlignStack(1024); >> return 1234; >> } >> >> It sets alignstack=1024 in the function attributes (see >> http://llvm.org/docs/LangRef.html#function-attributes). It's tripping an >> assert: >> >> llvm/lib/IR/Attributes.cpp:134: static llvm::Attribute >> llvm::Attribute::getWithStackAlignment(llvm::LLVMContext&, uint64_t): >> Assertion `Align <= 0x100 && "Alignment too large."' >> >> Is 0x100 the correct maximum alignstack value? Can I submit a patch to >> document this in LangRef.html? >> > > Yes...? But nobody should ever specify a value anywhere near that large. >Fair, but as a frontend I want to make this a friendly compile error and not a mysterious LLVM assertion failure :-)> > The point of the attribute is to fixup the stack alignment in cases of ABI > mismatches, so you normally don't want to specify a value higher than the > actual ABI alignment of the stack. If you want to allocate aligned memory > on the stack, you can just set the alignment of an alloca, and the code > generator will provide memory with the appropriate alignment.Good to know, thanks.> > > -Eli > > -- > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux > Foundation Collaborative Project > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171023/777d9fef/attachment.html>