chrib updated this revision to Diff 93631. chrib added a dependency: D31139: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed with EHABI. chrib added a comment.
1. Updating https://reviews.llvm.org/D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI # Set UNTable of the language requiers an exception table. Conservately only for ARM, necessary to emit the .cantunwind directive. But could probably be enabled for all targets. depends on https://reviews.llvm.org/D31139 https://reviews.llvm.org/D31140 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/CodeGenModule.h Index: lib/CodeGen/CodeGenModule.h =================================================================== --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,9 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + bool needsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,25 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::needsUnwindTable() { + if (CodeGenOpts.UnwindTables) + return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && Arch==llvm::Triple::arm; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (needsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind);
Index: lib/CodeGen/CodeGenModule.h =================================================================== --- lib/CodeGen/CodeGenModule.h +++ lib/CodeGen/CodeGenModule.h @@ -1341,6 +1341,9 @@ void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone, bool AttrOnCallSite, llvm::AttrBuilder &FuncAttrs); + + bool needsUnwindTable(); + }; } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CodeGenModule.cpp =================================================================== --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -865,13 +865,25 @@ return true; } +// This function needs an unwind table +bool CodeGenModule::needsUnwindTable() { + if (CodeGenOpts.UnwindTables) + return true; + + llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch(); + return hasUnwindExceptions (LangOpts) && Arch==llvm::Triple::arm; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { llvm::AttrBuilder B; - if (CodeGenOpts.UnwindTables) + // Set the attribute if the user requests it or if the language requiers it. + if (needsUnwindTable()) B.addAttribute(llvm::Attribute::UWTable); + // If the module doesn't support exceptions the function cannot throw. + // We can have a nothrow function even if unwind tables are required. if (!hasUnwindExceptions(LangOpts)) B.addAttribute(llvm::Attribute::NoUnwind);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits