For now, only support lowering frame/return address for current frame.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp | ||
|---|---|---|
| 241–246 | Good question! When the depth!=0 and the caller function does not use FP to save the current stack frame, causing an illegal address call, as in the following example: #include <stdio.h>
void __attribute__((noinline)) foo() {
  printf("foo\n");
  printf("return address: %p\n", __builtin_return_address(2));
}
void __attribute__((noinline)) bar() {
  foo();
  printf("bar\n");
  printf("return address: %p\n", __builtin_return_address(0));
}
int main() {
  bar();
  return 0;
}Compiling this test case with O2 on riscv64 reproduces this problem. | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr.ll | ||
| 7 | Thanks, I will modify it. | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr.ll | ||
|---|---|---|
| 51 | For an assertion build, this will crash. | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr.ll | ||
|---|---|---|
| 51 | Maybe this test can be removed before ; REQUIRES: noasserts getting supported by llvm-lit? | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr.ll | ||
|---|---|---|
| 51 | Thanks, I will remove it. | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll | ||
|---|---|---|
| 7 | The _0 suffix is needless as you don't have _1 or _2. | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll | ||
|---|---|---|
| 7 | Perhaps non_const_depth_frameaddress? | |
| llvm/test/CodeGen/LoongArch/frameaddr-returnaddr-error.ll | ||
|---|---|---|
| 7 | Thanks, I will modify it. | |
Seems that depth > 0 should also be supported (but not guarantee correctness). See D137541.
Why this limitation? I can't seem to find similar guard in AArch64, CSKY, RISCV or VE, but it is indeed present for MIPS and SystemZ.