Always add 'uwtable' attribute on x86_64.

This is what Clang does, and omitting it could lead to problems
w.r.t. the System V ABI. Doesn't seem to have caused any issues
so far, though.
This commit is contained in:
David Nadlinger
2013-05-19 21:47:15 +02:00
parent edbace8ae8
commit d402cd382e

View File

@@ -968,6 +968,19 @@ void DtoDefineFunction(FuncDeclaration* fd)
if (fd->isMain())
gIR->emitMain = true;
// On x86_64, always set 'uwtable' for System V ABI compatibility.
// TODO: Find a better place for this.
if (global.params.targetTriple.getArch() == llvm::Triple::x86_64)
{
#if LDC_LLVM_VER >= 303
func->addFnAttr(llvm::Attribute::UWTable);
#elif LDC_LLVM_VER == 302
func->addFnAttr(llvm::Attributes::UWTable);
#else
func->addFnAttr(UWTable);
#endif
}
std::string entryname("entry");
llvm::BasicBlock* beginbb = llvm::BasicBlock::Create(gIR->context(), entryname,func);