[PATCH] D36831: [AMDGPU] Transform __read_pipe_* and __write_pipe_*

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 09:55:18 PDT 2017


rampitec added inline comments.


================
Comment at: lib/Target/AMDGPU/AMDGPULibCalls.cpp:616
+
+  auto *F = M->getOrInsertFunction(Name, FTy);
+  auto *NCI = B.CreateCall(F, Args);
----------------
rampitec wrote:
> yaxunl wrote:
> > rampitec wrote:
> > > You should not use getOrInsertFunction directly, but use AMDGPULibCalls::getFunction().
> > > Since you are not using it you also fail to check we are in pre-link.
> > whether in pre-link can be checked by whether the function is declaration.
> > 
> > `__read_pipe_*` and `__write_pipe_*` are unmangled functions. AMDGPULibFunc::getFunction relies on argument information encoded in mangled function names, which does not work for unmangled functions.
> You are still using M->getOrInsertFunction() directly.
I see you are now checking for the declaration vs definition, but it is still only legal on pre-link and that is not checked.


================
Comment at: lib/Target/AMDGPU/AMDGPULibFunc.cpp:987
+bool UnmangledFuncInfo::lookup(StringRef Name, ID &Id) {
+  for (unsigned I = 0; I != TableSize; ++I) {
+    if (Name == Table[I].Name) {
----------------
yaxunl wrote:
> rampitec wrote:
> > I believe we can go without bruteforce search loop.
> will add a map.
Not done.


================
Comment at: lib/Target/AMDGPU/AMDGPULibFunc.h:366
 
-  void          reset();
+  static StringRef getUnmangledName(const StringRef &mangledName);
 
----------------
yaxunl wrote:
> rampitec wrote:
> > StringRef designed to be passed by value, here and below.
> This comes from the original implementation. Will fix.
Not done.


================
Comment at: test/CodeGen/AMDGPU/simplify-libcalls.ll:693
+entry:
+  %0 = bitcast i32 addrspace(1)* %ptr to i8 addrspace(1)*
+  %1 = addrspacecast i8 addrspace(1)* %0 to i8 addrspace(4)*
----------------
yaxunl wrote:
> rampitec wrote:
> > Run tests through opt -instnamer.
> will fix.
Not done.


https://reviews.llvm.org/D36831





More information about the llvm-commits mailing list