[PATCH] D103138: [AMDGPU] [IndirectCalls] Don't propagate attributes to address taken functions and their callees

Jon Chesterfield via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 23 18:32:10 PDT 2021


JonChesterfield added a comment.

This patch causes the amdgpu-propagate-attributes-late pass to loop forever when the input IR has a recursive function call (and a couple of other minor things). Reduced test case:

  target triple = "amdgcn-amd-amdhsa"
  
  define i64 @f(i64 %x)  {
  entry:
    br i1 undef, label %return, label %if.end
  
  if.end:
    %call = call i64 @f(i64 undef) 
    unreachable
  
  return:
    ret i64 1
  }
  
  define i8* @unrelated() {
  entry:
    ret i8* bitcast (i64 (i64)* @f to i8*)
  }
  
  declare amdgpu_kernel void @has_a_kernel(i32)

Reverting this patch fixes that - compilation proceeds correctly, instead of looping forever.

I believe this patch is an optimisation. Tests don't cover functional changes, there is no reference to a bug report and I can't think of anything this might be fixing. The commit message doesn't say what motivates the change. I'm therefore going to revert it on the basis that it is broken.

The attributor framework was written to factor out code very like this, and it won't fall over on a recursive function call, so my preference remains to change over to that instead of doing amdgpu-only callgraph walking stuff.



================
Comment at: llvm/test/CodeGen/AMDGPU/propagate-attributes-common-callees.ll:1
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-propagate-attributes-late  %s | FileCheck %s
+
----------------
I can't tell what this test is looking for. What do you mean by common callees here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103138



More information about the llvm-commits mailing list