[PATCH] Add the llvm.frameallocate and llvm.recoverframeallocation intrinsics

Reid Kleckner rnk at google.com
Thu Dec 18 11:32:13 PST 2014


================
Comment at: docs/LangRef.rst:7301
@@ +7300,3 @@
+'``llvm.frameallocate``' is allocated prior to stack realignment to produce a
+fixed offset from the frame pointer, so the memory is only aligned to the
+ABI-required stack alignment.  Each function may only call
----------------
echristo wrote:
> This doesn't appear to be true? The allocas seem to be merged and after alignment.
This is how I would *like* it to work. It isn't implemented. I'll weaken this to say it *may* be allocated prior to realignment.

================
Comment at: include/llvm/CodeGen/ISDOpcodes.h:75
@@ -74,1 +74,3 @@
 
+    RECOVER_FRAME_ALLOC,
+
----------------
echristo wrote:
> Needs docs.
done


================
Comment at: include/llvm/Target/Target.td:868
@@ +867,3 @@
+  let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
+  let hasSideEffects = 0;
+  let hasCtrlDep = 1;
----------------
echristo wrote:
> Might want to comment why both of these are true.
done

================
Comment at: lib/CodeGen/MachineFunction.cpp:591
@@ +590,3 @@
+int MachineFrameInfo::CreateFrameAllocation(uint64_t Size) {
+  // Force the use of a frame pointer. The intention is that this intrinsic be
+  // used in conjunction with unwind mechanisms that leak the frame pointer.
----------------
echristo wrote:
> If this is for a specific use you probably want to reference the intrinsic more directly in the name. Right now CreateFrameAllocation(size) sounds like something I'd call in general :)
It is named directly after the intrinsic, llvm.frameallocate. Can you propose a more specific name?

================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5582
@@ +5581,3 @@
+    // Do the allocation and map it as a normal value.
+    // FIXME: Maybe we should add this to the alloca map so that we don't have
+    // to register allocate it?
----------------
echristo wrote:
> Elaborate?
Every SSA value live across mutliple BBs has an associated virtual register except for static allocas. The address of a static alloca is essentially always rematerialized at the point of use by doing arithmetic on the stack pointer. The same could be done for the result of llvm.frameallocate in many cases. As it is, the code will be less optimal than it could be, but that seems OK.

================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5605
@@ +5604,3 @@
+    MachineFunction &MF = DAG.getMachineFunction();
+    MachineRegisterInfo &MRI = MF.getRegInfo();
+    const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();
----------------
echristo wrote:
> Unused.
done


================
Comment at: test/CodeGen/X86/frameallocate.ll:25
@@ +24,3 @@
+
+define void @alloc_func(i32* %s, i32* %d) {
+  %alloc = call i8* @llvm.frameallocate(i32 16)
----------------
echristo wrote:
> How about a couple tests that have both allocations and/or alignment requirements?
I could do that, but it wouldn't work since it's not implemented. :)

http://reviews.llvm.org/D6493

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list