Index: lib/Target/AMDGPU/AMDGPULibFunc.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPULibFunc.cpp +++ lib/Target/AMDGPU/AMDGPULibFunc.cpp @@ -995,8 +995,10 @@ } else { AttributeList Attr; LLVMContext &Ctx = M->getContext(); - Attr.addAttribute(Ctx, AttributeList::FunctionIndex, Attribute::ReadOnly); - Attr.addAttribute(Ctx, AttributeList::FunctionIndex, Attribute::NoUnwind); + Attr = Attr.addAttribute(Ctx, AttributeList::FunctionIndex, + Attribute::ReadOnly); + Attr = Attr.addAttribute(Ctx, AttributeList::FunctionIndex, + Attribute::NoUnwind); C = M->getOrInsertFunction(FuncName, FuncTy, Attr); } Index: test/CodeGen/AMDGPU/simplify-libcalls.ll =================================================================== --- test/CodeGen/AMDGPU/simplify-libcalls.ll +++ test/CodeGen/AMDGPU/simplify-libcalls.ll @@ -783,5 +783,10 @@ ret void } +; GCN-PRELINK: declare float @_Z4fabsf(float) local_unnamed_addr #[[NOUNWIND_READONLY:[0-9]+]] +; GCN-PRELINK: declare float @_Z4cbrtf(float) local_unnamed_addr #[[NOUNWIND_READONLY]] +; GCN-PRELINK: declare float @_Z11native_sqrtf(float) local_unnamed_addr #[[NOUNWIND_READONLY]] + ; CGN-PRELINK: attributes #[[$NOUNWIND]] = { nounwind } +; GCN-PRELINK: attributes #[[NOUNWIND_READONLY]] = { nounwind readonly } attributes #0 = { nounwind }