From d402cd382e3679d669fec5ad0950397a6a886176 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 19 May 2013 21:47:15 +0200 Subject: [PATCH] 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. --- gen/functions.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gen/functions.cpp b/gen/functions.cpp index bee0c17f..bfca527f 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -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);