
This patch is part of a set of patches that add an `-fextend-lifetimes` flag to clang, which extends the lifetimes of local variables and parameters for improved debuggability. In addition to that flag, the patch series adds a pragma to selectively disable `-fextend-lifetimes`, and an `-fextend-this-ptr` flag which functions as `-fextend-lifetimes` for this pointers only. All changes and tests in these patches were written by Wolfgang Pieb (@wolfy1961), while Stephen Tozer (@SLTozer) has handled review and merging. The extend lifetimes flag is intended to eventually be set on by `-Og`, as discussed in the RFC here: https://discourse.llvm.org/t/rfc-redefine-og-o1-and-add-a-new-level-of-og/72850 This patch implements a new intrinsic instruction in LLVM, `llvm.fake.use` in IR and `FAKE_USE` in MIR, that takes a single operand and has no effect other than "using" its operand, to ensure that its operand remains live until after the fake use. This patch does not emit fake uses anywhere; the next patch in this sequence causes them to be emitted from the clang frontend, such that for each variable (or this) a fake.use operand is inserted at the end of that variable's scope, using that variable's value. This patch covers everything post-frontend, which is largely just the basic plumbing for a new intrinsic/instruction, along with a few steps to preserve the fake uses through optimizations (such as moving them ahead of a tail call or translating them through SROA). Co-authored-by: Stephen Tozer <stephen.tozer@sony.com>
44 lines
1.4 KiB
LLVM
44 lines
1.4 KiB
LLVM
; RUN: llc -O0 -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
|
|
|
|
; Checks that fake uses of the FP stack do not cause a crash.
|
|
;
|
|
; /*******************************************************************/
|
|
; extern long double foo(long double, long double, long double);
|
|
;
|
|
; long double actual(long double p1, long double p2, long double p3) {
|
|
; return fmal(p1, p2, p3);
|
|
; }
|
|
; /*******************************************************************/
|
|
|
|
define x86_fp80 @actual(x86_fp80 %p1, x86_fp80 %p2, x86_fp80 %p3) optdebug {
|
|
;
|
|
; CHECK: actual
|
|
;
|
|
entry:
|
|
%p1.addr = alloca x86_fp80, align 16
|
|
%p2.addr = alloca x86_fp80, align 16
|
|
%p3.addr = alloca x86_fp80, align 16
|
|
store x86_fp80 %p1, ptr %p1.addr, align 16
|
|
store x86_fp80 %p2, ptr %p2.addr, align 16
|
|
store x86_fp80 %p3, ptr %p3.addr, align 16
|
|
%0 = load x86_fp80, ptr %p1.addr, align 16
|
|
%1 = load x86_fp80, ptr %p2.addr, align 16
|
|
%2 = load x86_fp80, ptr %p3.addr, align 16
|
|
;
|
|
; CHECK: callq{{.*}}foo
|
|
;
|
|
%3 = call x86_fp80 @foo(x86_fp80 %0, x86_fp80 %1, x86_fp80 %2)
|
|
%4 = load x86_fp80, ptr %p1.addr, align 16
|
|
call void (...) @llvm.fake.use(x86_fp80 %4)
|
|
%5 = load x86_fp80, ptr %p2.addr, align 16
|
|
call void (...) @llvm.fake.use(x86_fp80 %5)
|
|
%6 = load x86_fp80, ptr %p3.addr, align 16
|
|
call void (...) @llvm.fake.use(x86_fp80 %6)
|
|
;
|
|
; CHECK: ret
|
|
;
|
|
ret x86_fp80 %3
|
|
}
|
|
|
|
declare x86_fp80 @foo(x86_fp80, x86_fp80, x86_fp80)
|