[PATCH] D123198: [LibCalls] Add argument extension attributes to more functions.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 04:48:05 PDT 2022


jonpa added a comment.

> We can't just skip adding the attributes: we end up generating a broken call that won't perform the necessary sign-extension.  So it breaks even if the alias points to a proper fwrite implementation.  (Even if we don't technically promise anything in this case, generating a call that's provably broken is bad.)

OK - we don't have the responsibility here but it would help to hurt if we could, makes sense.

I started look into the difference in having a function alias replacing a libcall, and was surprised to find that the final assembly output is actually identical, which I hadn't expected. I was assuming that in the following program @__ldexp_alias() would end up being called:

  @ldexp = alias double (double, i32), double (double, i32)* @__ldexp_alias
  define double @__ldexp_alias(double %X, i32 %Exp) #0 {
   ret double 0.000000e+00
  }
  ;declare double @ldexp(double, i32) 
  
  define double @fake_ldexp() #0 {
    %ldexp = call double @ldexp(double 1.000000e+00, i32 2)
    ret double %ldexp
  }

It however has no difference as to when the "declare @ldexp" is used instead... In both cases SelectionDAGBuilder creates a node like

  i64 = GlobalAddress<double (double, i32)* @ldexp> 0

Resulting in

  brasl   %r14, ldexp at PLT

The function with the name of the alias is called even though that is not supposed to exist on its own (same thing with non library like name)... Not sure what to think of this... Maybe I am using the alias incorrectly somehow?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123198



More information about the llvm-commits mailing list