[PATCH] D55435: [AMDGPU] Fix discarded result of addAttribute

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 9 09:03:52 PST 2018


modocache updated this revision to Diff 177440.
modocache added a comment.

I see, thanks @arsenm! I think this variable fits those criteria so I changed it back to using a dollar-sign prefix. Variable names notwithstanding, does the implementation change seem OK to everyone? It fixes what I believe is clearly a programming error. Landing this change will unblock me from LLVM_NODISCARD to these functions and so preventing another case of this same error.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55435/new/

https://reviews.llvm.org/D55435

Files:
  lib/Target/AMDGPU/AMDGPULibFunc.cpp
  test/CodeGen/AMDGPU/simplify-libcalls.ll


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 }
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);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55435.177440.patch
Type: text/x-patch
Size: 1441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181209/64afc7c1/attachment.bin>


More information about the llvm-commits mailing list