[PATCH] D135738: [InstCombine] Bail out of casting calls when a conversion to byval is involved.

Mike Hommey via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 12 01:31:45 PDT 2022


glandium added a comment.

It looks like it's not a problem:

  cat <<EOF | opt --O3 -S
  target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
  target triple = "i686-unknown-linux-gnu"
  
  define ptr @bar(ptr %0) {
    %2 = tail call ptr @foo(ptr %0)
  ; CHECK: %2 = tail call ptr @foo(ptr %0)
    ret ptr %2
  }
  
  %Foo = type { ptr }
  define ptr @foo (ptr byval(%Foo) %foo) {
    %1 = load ptr, ptr %foo, align 4
    ret ptr %1
  }
  EOF
  ; ModuleID = '<stdin>'
  source_filename = "<stdin>"
  target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
  target triple = "i686-unknown-linux-gnu"
  
  %Foo = type { ptr }
  
  ; Function Attrs: argmemonly mustprogress nofree norecurse nosync nounwind readonly willreturn
  define ptr @bar(ptr nocapture readonly %0) local_unnamed_addr #0 {
    %2 = load ptr, ptr %0, align 4
    ret ptr %2
  }
  
  ; Function Attrs: argmemonly mustprogress nofree norecurse nosync nounwind readonly willreturn
  define ptr @foo(ptr nocapture readonly byval(%Foo) %foo) local_unnamed_addr #0 {
    %1 = load ptr, ptr %foo, align 4
    ret ptr %1
  }
  
  attributes #0 = { argmemonly mustprogress nofree norecurse nosync nounwind readonly willreturn }

(that's without the patch applied, btw ; with or without the patch makes no difference in this case)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135738



More information about the llvm-commits mailing list