Incorrect const loaded into reg while passing args
For the below trivial C code, the oraFoo() function is passing all const args as numeric zero at all optimization level other than -O0. Even though the args not used in callee, there is no benefits of loading reg with numeric ZERO rather than its actual value.
#include <stdio.h>
typedef unsigned char ub1;
void oraSetRegInfo(ub1);
void __attribute__((noinline)) oraBar(ub1 var1, ub1 var2, ub1 var3, ub1 var4,
ub1 var5, ub1 var6, ub1 var7,
ub1 var8, ub1 var9)
{
oraSetRegInfo(var9);
}
void __attribute__((noinline)) oraFoo()
{
ub1 var = 255;
oraBar(10, 20, 30, 40, 50, 60, 70, 80, var);
}
Please see the example assembly code here, https://godbolt.org/z/Kcqz7Enen
@llvm/issue-subscribers-backend-powerpc
Author: Ishwara Sharma (IshwaraK)
#include <stdio.h>
typedef unsigned char ub1;
void oraSetRegInfo(ub1);
void __attribute__((noinline)) oraBar(ub1 var1, ub1 var2, ub1 var3, ub1 var4,
ub1 var5, ub1 var6, ub1 var7,
ub1 var8, ub1 var9)
{
oraSetRegInfo(var9);
}
void __attribute__((noinline)) oraFoo()
{
ub1 var = 255;
oraBar(10, 20, 30, 40, 50, 60, 70, 80, var);
}
Please see the example assembly code here, https://godbolt.org/z/Kcqz7Enen
This is in no way specific to PowerPC. It is simply an artifact of the IR specifying those arguments as poison values. There are other targets that do the same thing with this code (armv7, RISC-V, etc.).