llvm.org GIT mirror llvm / 515714f
Fix the lowering issue of intrinsics llvm.localaddress on X86 Patch by Yuanke Luo Reviewers: craig.topper, annita.zhang, smaslov, rnk, wxiao3 Reviewed By: rnk Subscribers: efriedma, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57501 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353492 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 1 year, 6 months ago
4 changed file(s) with 95 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2255722557 unsigned Reg;
2255822558 if (RegInfo->hasBasePointer(MF))
2255922559 Reg = RegInfo->getBaseRegister();
22560 else // This function handles the SP or FP case.
22561 Reg = RegInfo->getPtrSizedFrameRegister(MF);
22560 else { // Handles the SP or FP case.
22561 bool CantUseFP = RegInfo->needsStackRealignment(MF);
22562 if (CantUseFP)
22563 Reg = RegInfo->getPtrSizedStackRegister(MF);
22564 else
22565 Reg = RegInfo->getPtrSizedFrameRegister(MF);
22566 }
2256222567 return DAG.getCopyFromReg(DAG.getEntryNode(), dl, Reg, VT);
2256322568 }
2256422569 }
761761 FrameReg = getX86SubSuperRegister(FrameReg, 32);
762762 return FrameReg;
763763 }
764
765 unsigned
766 X86RegisterInfo::getPtrSizedStackRegister(const MachineFunction &MF) const {
767 const X86Subtarget &Subtarget = MF.getSubtarget();
768 unsigned StackReg = getStackRegister();
769 if (Subtarget.isTarget64BitILP32())
770 StackReg = getX86SubSuperRegister(StackReg, 32);
771 return StackReg;
772 }
129129 // Debug information queries.
130130 unsigned getFrameRegister(const MachineFunction &MF) const override;
131131 unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const;
132 unsigned getPtrSizedStackRegister(const MachineFunction &MF) const;
132133 unsigned getStackRegister() const { return StackPtr; }
133134 unsigned getBaseRegister() const { return BasePtr; }
134135 /// Returns physical register used as frame pointer.
0 ; RUN: llc -mtriple x86_64-pc-windows-msvc -o - %s | FileCheck %s
1
2 ; struct S { int x; };
3 ; void foo() {
4 ; struct S __declspec(align(32)) o;
5 ; __try { o.x; }
6 ; __finally { o.x; }
7 ; }
8 ; void bar() {
9 ; struct S o;
10 ; __try { o.x; }
11 ; __finally { o.x; }
12 ; }
13
14 %struct.S = type { i32 }
15
16 define dso_local void @"?foo@@YAXXZ"() #0 {
17 entry:
18 ; CHECK-LABEL: foo
19 ; CHECK: movq %rsp, %rdx
20 ; CHECK-NOT: movq %rbp, %rdx
21
22 %o = alloca %struct.S, align 32
23 call void (...) @llvm.localescape(%struct.S* %o)
24 %x = getelementptr inbounds %struct.S, %struct.S* %o, i32 0, i32 0
25 %0 = call i8* @llvm.localaddress()
26 call void @"?fin$0@0@foo@@"(i8 0, i8* %0)
27 ret void
28 }
29
30 ; void bar(void)
31 ; {
32 ; int x;
33 ; void (*fn)(int);
34 ;
35 ; __try {
36 ; x = 1;
37 ; fn(x);
38 ; } __finally {
39 ; x = 2;
40 ; }
41 ; }
42
43 define dso_local void @"?bar@@YAXXZ"() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
44 entry:
45 ; CHECK-LABEL: bar
46 ; CHECK: movq %rbp, %rdx
47 ; CHECK-NOT: movq %rsp, %rdx
48 %x = alloca i32, align 4
49 %fn = alloca void (i32)*, align 8
50 call void (...) @llvm.localescape(i32* %x)
51 store i32 1, i32* %x, align 4
52 %0 = load void (i32)*, void (i32)** %fn, align 8
53 %1 = load i32, i32* %x, align 4
54 invoke void %0(i32 %1)
55 to label %invoke.cont unwind label %ehcleanup
56 invoke.cont: ; preds = %entry
57 %2 = call i8* @llvm.localaddress()
58 call void @"?fin$0@0@bar@@"(i8 0, i8* %2)
59 ret void
60 ehcleanup: ; preds = %entry
61 %3 = cleanuppad within none []
62 %4 = call i8* @llvm.localaddress()
63 call void @"?fin$0@0@bar@@"(i8 1, i8* %4) [ "funclet"(token %3) ]
64 cleanupret from %3 unwind to caller
65 }
66
67 declare void @"?fin$0@0@foo@@"(i8 %abnormal_termination, i8* %frame_pointer)
68
69 declare void @"?fin$0@0@bar@@"(i8 %abnormal_termination, i8* %frame_pointer)
70
71 declare i8* @llvm.localrecover(i8*, i8*, i32)
72
73 declare i8* @llvm.localaddress()
74
75 declare void @llvm.localescape(...)
76
77 declare dso_local i32 @__C_specific_handler(...)