[PATCH] D19368: Allow Sparc back-end to take the address of a function (or other global object)

Chris Dewhurst via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 08:36:08 PDT 2016


lero_chris created this revision.
lero_chris added a reviewer: jacob_hansen.
lero_chris added subscribers: jacob_hansen, jyknight, llvm-commits.
lero_chris set the repository for this revision to rL LLVM.

The following code would not work before this patch, due to the inability to take the address of a global object:

void func1() {
  ...
}

int main(int argc, char** argv) {
  void (*pFunc)();
  pFunc = &func1
  pFunc();
  ...
}


Repository:
  rL LLVM

http://reviews.llvm.org/D19368

Files:
  DelaySlotFiller.cpp

Index: DelaySlotFiller.cpp
===================================================================
--- DelaySlotFiller.cpp
+++ DelaySlotFiller.cpp
@@ -296,7 +296,7 @@
     RegUses.insert(Reg.getReg());
 
     const MachineOperand &RegOrImm = MI->getOperand(1);
-    if (RegOrImm.isImm())
+    if (RegOrImm.isImm() || RegOrImm.isGlobal())
         break;
     assert(RegOrImm.isReg() && "CALLrr second operand is not a register.");
     assert(RegOrImm.isUse() && "CALLrr second operand is not a use.");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19368.54513.patch
Type: text/x-patch
Size: 499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160421/cafac1b8/attachment.bin>


More information about the llvm-commits mailing list