[llvm-bugs] [Bug 121135] ARM32: Missing gprof support

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121135




Summary

ARM32: Missing gprof support




  Labels
  
backend:ARM
  



  Assignees
  
  



  Reporter
  
  wzssyqa
  




```
int fib(int n) {return n <=1 ? 1 : fib(n-1) + fib(n-2); }
int main() {fib(10); return 0;}
```

How to test native:
```
bin/clang -pg test.c && ./a.out && gprof -b a.out gmon.out
```

How to test cross with qemu-user
```
apt install gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf
bin/clang --target=arm-linux-gnueabi -pg test.c -static && ./a.out && gprof -b a.out gmon.out
bin/clang --target=arm-linux-gnueabihf -pg test.c -static && ./a.out && gprof -b a.out gmon.out
```

Known problem:
```
$ bin/clang --target=arm-linux-gnueabi -pg test.c -static && ./a.out && gprof -b a.out gmon.out
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self  self total 
 time   seconds   secondscalls  Ts/call  Ts/call  name 


			Call graph


granularity: each sample hit covers 2 byte(s) no time propagated

index % timeself  childrencalled name
 1 main [130]
[130]0.00.00 0.00   0+1   main [130]
   1 main [130]
---


Index by function name
```

```
$ bin/clang --target=arm-linux-gnueabihf -pg test.c -static && ./a.out && gprof -b a.out gmon.out
/usr/bin/arm-linux-gnueabihf-ld: /tmp/n-9e8be5.o: in function `fib':
n.c:(.text+0xc): undefined reference to `mcount'
/usr/bin/arm-linux-gnueabihf-ld: /tmp/n-9e8be5.o: in function `main':
n.c:(.text+0x4c): undefined reference to `mcount'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121125] [Flang] Performance issues in assignments

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121125




Summary

[Flang] Performance issues in assignments




  Labels
  
performance,
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  




[The measurement](https://discourse.llvm.org/t/optimization-of-complex-number-division/83468/1) of the performance of 627.cam4_s shows that assignments for non-contiguous arrays spends time.  
I checked the performance of some kinds of assignments and found issues. This issue intends to track the status of those issues. Any help is welcome.

## Issue list
 - [ ] [Flang] Assignments for local non-contiguous allocatable arrays are slower than GFortran
 - [ ] [Flang] Assignments for arrays of a derived type are slower than GFortran
 - [ ] [Flang] Assignments for overlapping arrays of a derived type with FORALL/WHERE are slower than GFortran
 - [ ] [Flang] Assignments for integer arrays with FORALL/WHERE are slower than GFortran
 - [ ] [Flang] Defined assignments are slower than GFortran
 - [ ] [Flang] Assignments for complex variables are slower than GFortran
 - [ ] [Flang] Assignments for variables of a derived type are slower than GFortran
 - [ ] [Flang] Pointer assignments for scalar pointers are slower than GFortran
 - [ ] [Flang] Pointer assignments for array pointers are slower than GFortran


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121126] [Flang] Assignments for local non-contiguous allocatable arrays are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121126




Summary

[Flang] Assignments for local non-contiguous allocatable arrays are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121136] Missing gprof support on some target

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121136




Summary

Missing gprof support on some target




  Labels
  
new issue
  



  Assignees
  
  



  Reporter
  
  wzssyqa
  




Test code
```
; bin/clang -pg test.c && ./a.out && gprof -b a.out gmon.out
int fib(int n) {return n <=1 ? 1 : fib(n-1) + fib(n-2); }
int main() {fib(10); return 0;}
```

Known workable platforms
```
X86-64
X86-32
MIPS32
MIPS64
SPARC64
PowerPC64LE
```

Known unworkable platforms
```
AARCH64 https://github.com/llvm/llvm-project/pull/121107
LoongArch64 https://github.com/llvm/llvm-project/pull/121107
RISC-V64 https://github.com/llvm/llvm-project/pull/121107
ARM32: https://github.com/llvm/llvm-project/issues/121135
S390X/SystemZ
```


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121137] SystemZ: Missing gprof support

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121137




Summary

SystemZ: Missing gprof support




  Labels
  
new issue
  



  Assignees
  
  



  Reporter
  
  wzssyqa
  




```
int fib(int n) {return n <=1 ? 1 : fib(n-1) + fib(n-2); }
int main() {fib(10); return 0;}
```

How to test native:
```
bin/clang -pg test.c && ./a.out && gprof -b a.out gmon.out
```

How to test cross with qemu-user
```
apt install gcc-s390x-linux-gnu qemu-user-static
bin/clang --target=s390x-linux-gnu -pg test.c -static && ./a.out && gprof -b a.out gmon.out
```

Known problem:
```
$ bin/clang --target=s390x-linux-gnu -pg n.c -O2 -static && ./a.out && gprof -b ./a.out gmon.out 
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self self total   
 time   seconds   secondscalls  Ts/call Ts/call  name  
```




___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121142] Can't specify a physical register in inline assembly issue

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121142




Summary

Can't specify a physical register in inline assembly issue




  Labels
  
new issue
  



  Assignees
  
  



  Reporter
  
  LuoYuanke
  




It seems below inline assembly fails to be compiled with clang, but can be successful compiled with GCC. It can be duplicated in https://godbolt.org/z/xhrq6YEvT

```
void foo() {
  int src = ""
  int dst, dst2;

  asm("movl %1, %0\n\t"
  "addl $1, %0"
  : "=eax"(dst)
  : "i"(1));
}
```




___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121108] [Clang] Missing flag to allow using `[[gnu::init_priority]]` in source files

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121108




Summary

[Clang] Missing flag to allow using `[[gnu::init_priority]]` in source files




  Labels
  
clang
  



  Assignees
  
  



  Reporter
  
  philnik777
  




Currently it's not possible to use `[[gnu::init_priority(100)]]` in source files except by using line control markers. It would be way nicer if there was a diagnostic group to disable this with the diagnostic being an error by default. GCC currently accepts this with a warning without a group instead, which is also annoying, but not as bad as making it only possible with a hack.



___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121105] [LLVM] Inlining breaks __builtin_expect branch weight metadata

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121105




Summary

[LLVM] Inlining breaks __builtin_expect branch weight metadata




  Labels
  
new issue
  



  Assignees
  
  



  Reporter
  
  sillycross
  




Minimal repro:
```
#define likely(expr) __builtin_expect((expr) != 0, 1)
bool f(int** p) {
  return *p != nullptr && **p == 1;
}
void h();
void i();
void g(int** p) {
  if (likely(f(p))) h(); else i();
}
```
Compile: `clang++ test.cpp -O3 -emit-llvm -S` gives following result ([https://godbolt.org/z/81rrxbhab](https://godbolt.org/z/81rrxbhab)):
```
... omitted ...
  %6 = icmp eq i32 %5, 1# <- **p == 1 check
  br i1 %6, label %7, label %8, !prof !49   # <- metadata broken
... omitted ...
  # -2147483648 means invalid. Should be "i32 2000, i32 1" (due to __builtin_expect)
  !49 = !{!"branch_weights", !"expected", i32 -2147483648, i32 0}  
```

After bisecting, this bug is introduced by commit [#a1b78fb](https://github.com/llvm/llvm-project/commit/a1b78fb929fccf96acaa0212cf68fee82298e747), authored by Evgeniy Brevnov (ybrev...@azul.com) and reviewed by @xortator (Max Kazantsev). Reverting the commit fixes the issue.

Ironically, this commit is already breaking existing tests by producing invalid metadata (see [#a1b78fb](https://github.com/llvm/llvm-project/commit/a1b78fb929fccf96acaa0212cf68fee82298e747) at the end). Instead of fixing the issues, the author changed the expected test output to the invalid metadata.


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121103] [AArch64][RISCV][Loongarch] return address should be passed into `_mcount`

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121103




Summary

[AArch64][RISCV][Loongarch] return address should be passed into `_mcount`




  Labels
  
backend:AArch64,
backend:RISC-V,
miscompilation,
backend:loongarch
  



  Assignees
  
dtcxzyw
  



  Reporter
  
  dtcxzyw
  




Reproducer:
```
; bin/clang -pg test.c && ./a.out && gprof -b a.out gmon.out
int fib(int n) {return n <=1 ? 1 : fib(n-1) + fib(n-2); }
int main() {fib(10); return 0;}
```
The call graph is missing if it is compiled with clang:
```
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  % cumulative   self  self total   
 time   seconds secondscalls  Ts/call  Ts/call  name
```
With gcc, it works as expected:
```
Flat profile:

Each sample counts as 0.01 seconds.
 no time accumulated

  %   cumulative   self  self total 
 time   seconds   secondscalls  Ts/call  Ts/call  name
  0.00 0.00 0.001 0.00 0.00  fib


 Call graph


granularity: each sample hit covers 2 byte(s) no time propagated

index % timeself  childrencalled name
 176 fib [1]
0.000.00 1/1   main [6]
[1]  0.00.000.00   1+176 fib [1]
 176 fib [1]
---


Index by function name

   [1] fib
```
This issue can be reproduced on AArch64/RISCV/Loongarch platforms.

After investing this issue, I found that we should pass the return address into `_mcount`:
https://github.com/gcc-mirror/gcc/blob/c6b7d0343f2c0eb3102341c9326fe314a047bee6/gcc/config/riscv/riscv.h#L466-L473
https://github.com/bminor/glibc/blob/757ac24f8f2344e5f8afd2465c808d0f6adcc948/sysdeps/riscv/machine-gmon.h

This issue was originally reported by @wzssyqa.



___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121110] [clang] Miscompile at -Os

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121110




Summary

[clang] Miscompile at -Os




  Labels
  
  



  Assignees
  
  



  Reporter
  
  cardigan1008
  




This code prints 9 at `-Os` and 0 at `-O0/1/2/3`:

```c
int printf(const char *, ...);
char a = 9, c, d;
int b, e;
unsigned short f;
char *g = &a;
void h(int i) {
  for (; b; b++)
c &= 0 <= i;
}
static short j(unsigned long i) {
  int k;
  for (; e + d + 4 > 0;) {
k = i + 49;
 h(k + i - 52 + i);
*g = 0;
return 0;
  }
  return 0;
}
int main() {
  j(6 < (unsigned short)(f - 7) + f);
  printf("%d\n", a);
}
```

Compiler Explorer: https://godbolt.org/z/Mo5TEKh8r

Bisected to https://github.com/llvm/llvm-project/commit/5287299f8809ae927a0acafb179c4b37ce9ff21d, which was committed by @RKSimon 


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121119] MCAsmStreamer: Omit initial ".text" causing lot of breakages

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121119




Summary

MCAsmStreamer: Omit initial ".text" causing lot of breakages




  Labels
  
new issue
  



  Assignees
  
  



  Reporter
  
  pranavk
  




@MaskRay 

https://github.com/llvm/llvm-project/commit/7b23f413d1f76532825e470b523e971818d453ca#diff-c1cd0d8700618033d5c6439791e7203361e531ee49f9a53865ca158302a79adc is causing us a lot of problems. I know you have changed all the tests that were dependent on it in the LLVM repo but it's a disruptive change in general. I am trying to fix-forward but failing that, could we revert this and reland it later after the holidays?


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121122] [amdgpu] Using fp128 fails with unsupported libcalls

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121122




Summary

[amdgpu] Using fp128 fails with unsupported libcalls




  Labels
  
backend:AMDGPU
  



  Assignees
  
  



  Reporter
  
  Flakebi
  




`fp128` seems to work fine in arguments and return values, but trying to do computations like `fmul` or `fdiv` fails:
```llvm
target triple = "amdgcn-amd-amdhsa"

define fp128 @fp128(fp128 %a, fp128 %b) {
  %res = fmul fp128 %a, %b
  ret fp128 %res
}
```
results in
```
LLVM ERROR: unsupported libcall legalization
Stack dump:
…
#10 llvm::SITargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl&) const llvm-project/llvm/lib/Target/AMDGPU/SIISelLowering.cpp:3877:34
```

I assume this is expected.
I encountered this while trying to compile Rust code, see also https://github.com/rust-lang/compiler-builtins/pull/737.


___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121131] [Flang] Assignments for complex variables are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121131




Summary

[Flang] Assignments for complex variables are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121128] [Flang] Assignments for overlapping arrays of a derived type with FORALL/WHERE are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121128




Summary

[Flang] Assignments for overlapping arrays of a derived type with FORALL/WHERE are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121132] [Flang] Assignments for variables of a derived type are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121132




Summary

[Flang] Assignments for variables of a derived type are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121134] [Flang] Pointer assignments for array pointers are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121134




Summary

[Flang] Pointer assignments for array pointers are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121129] [Flang] Assignments for integer arrays with FORALL/WHERE are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121129




Summary

[Flang] Assignments for integer arrays with FORALL/WHERE are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121127] [Flang] Assignments for arrays of a derived type are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121127




Summary

[Flang] Assignments for arrays of a derived type are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121130] [Flang] Defined assignments are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121130




Summary

[Flang] Defined assignments are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs


[llvm-bugs] [Bug 121133] [Flang] Pointer assignments for scalar pointers are slower than GFortran

2024-12-25 Thread LLVM Bugs via llvm-bugs


Issue

121133




Summary

[Flang] Pointer assignments for scalar pointers are slower than GFortran




  Labels
  
flang
  



  Assignees
  
  



  Reporter
  
  yus3710-fj
  







___
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs