[PATCH] D85573: [CGAtomic] Mark atomic libcall functions `nounwind`
Gui Andrade via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 14 00:48:56 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG909a851dbffe: [CGAtomic] Mark atomic libcall functions `nounwind` (authored by guiand).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85573/new/
https://reviews.llvm.org/D85573
Files:
clang/lib/CodeGen/CGAtomic.cpp
clang/test/CodeGen/atomic_ops.c
Index: clang/test/CodeGen/atomic_ops.c
===================================================================
--- clang/test/CodeGen/atomic_ops.c
+++ clang/test/CodeGen/atomic_ops.c
@@ -26,6 +26,9 @@
}
+// LIBCALL: declare void @__atomic_load(i32, i8*, i8*, i32) [[LC_ATTRS:#[0-9]+]]
+// LIBCALL: declare i1 @__atomic_compare_exchange(i32, i8*, i8*, i8*, i32, i32) [[LC_ATTRS:#[0-9]+]]
+
extern _Atomic _Bool b;
_Bool bar() {
@@ -53,6 +56,8 @@
x += y;
}
+// LIBCALL: declare void @__atomic_store(i32, i8*, i8*, i32) [[LC_ATTRS:#[0-9]+]]
+
_Atomic(int) compound_add(_Atomic(int) in) {
// CHECK-LABEL: @compound_add
// CHECK: [[OLD:%.*]] = atomicrmw add i32* {{.*}}, i32 5 seq_cst
@@ -107,3 +112,5 @@
return (in *= 5);
}
+
+// LIBCALL: [[LC_ATTRS]] = { nounwind willreturn }
Index: clang/lib/CodeGen/CGAtomic.cpp
===================================================================
--- clang/lib/CodeGen/CGAtomic.cpp
+++ clang/lib/CodeGen/CGAtomic.cpp
@@ -307,7 +307,14 @@
const CGFunctionInfo &fnInfo =
CGF.CGM.getTypes().arrangeBuiltinFunctionCall(resultType, args);
llvm::FunctionType *fnTy = CGF.CGM.getTypes().GetFunctionType(fnInfo);
- llvm::FunctionCallee fn = CGF.CGM.CreateRuntimeFunction(fnTy, fnName);
+ llvm::AttrBuilder fnAttrB;
+ fnAttrB.addAttribute(llvm::Attribute::NoUnwind);
+ fnAttrB.addAttribute(llvm::Attribute::WillReturn);
+ llvm::AttributeList fnAttrs = llvm::AttributeList::get(
+ CGF.getLLVMContext(), llvm::AttributeList::FunctionIndex, fnAttrB);
+
+ llvm::FunctionCallee fn =
+ CGF.CGM.CreateRuntimeFunction(fnTy, fnName, fnAttrs);
auto callee = CGCallee::forDirect(fn);
return CGF.EmitCall(fnInfo, callee, ReturnValueSlot(), args);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85573.285571.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200814/4f2829c7/attachment.bin>
More information about the cfe-commits
mailing list