llvm.org GIT mirror llvm / 90904c6
[AVR] Fix indirect calls to function pointers Patch by Carl Peto. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307888 91177308-0d34-0410-b5e6-96231b3b80d8 Dylan McKay 3 years ago
2 changed file(s) with 29 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3636 Expr, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
3737 }
3838
39 bool IsFunction = MO.isGlobal() && isa(MO.getGlobal());
40
3941 if (TF & AVRII::MO_LO) {
40 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_LO8, Expr, IsNegated, Ctx);
42 if (IsFunction) {
43 // N.B. Should we use _GS fixups here to cope with >128k progmem?
44 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_PM_LO8, Expr, IsNegated, Ctx);
45 } else {
46 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_LO8, Expr, IsNegated, Ctx);
47 }
4148 } else if (TF & AVRII::MO_HI) {
42 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_HI8, Expr, IsNegated, Ctx);
49 if (IsFunction) {
50 // N.B. Should we use _GS fixups here to cope with >128k progmem?
51 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_PM_HI8, Expr, IsNegated, Ctx);
52 } else {
53 Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_HI8, Expr, IsNegated, Ctx);
54 }
4355 } else if (TF != 0) {
4456 llvm_unreachable("Unknown target flag on symbol operand");
4557 }
0 ; RUN: llc -mattr=lpm,lpmw < %s -march=avr | FileCheck %s
1
2 declare void @callback(i16 zeroext)
3
4 ; CHECK-LABEL: foo
5 define void @foo() {
6 entry:
7 ; CHECK: ldi r{{[0-9]+}}, pm_lo8(callback)
8 ; CHECK-NEXT: ldi r{{[0-9]+}}, pm_hi8(callback)
9 call void @bar(i8 zeroext undef, void (i16)* @callback)
10 ret void
11 }
12
13 declare void @bar(i8 zeroext, void (i16)*)
14