[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI
Christian Bruel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 6 01:53:25 PDT 2017
chrib updated this revision to Diff 94329.
chrib added a comment.
- NeedsUnwindTable check thumb arch
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,11 @@
void ConstructDefaultFnAttrList(StringRef Name, bool HasOptnone,
bool AttrOnCallSite,
llvm::AttrBuilder &FuncAttrs);
+
+ /// Check whether the attribute UWTable must be set to emit the unwind table
+ /// for exceptions
+ bool NeedsUnwindTable();
+
};
} // end namespace CodeGen
} // end namespace clang
Index: lib/CodeGen/CodeGenModule.cpp
===================================================================
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -865,13 +865,27 @@
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 ||
+ Arch == llvm::Triple::thumb);
+}
+
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31140.94329.patch
Type: text/x-patch
Size: 1732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170406/042d405f/attachment.bin>
More information about the cfe-commits
mailing list