Segmented Stacks (re-roll)

Current set of patches for my work on segmented stacks. Go / dragonegg
seems to work when using this code (I still haven't run any rigorous
tests yet).

Thanks!

(Also on https://github.com/sanjoy/LLVM/tree/segmented-stacks)

0001-New-command-line-option-to-enable-segmented-stacks.patch (1.66 KB)

0002-New-StackSegmenter-pass.patch (6.78 KB)

0003-Prologue-code-emission-for-X86.patch (11.4 KB)

0004-New-SelectionDAG-node-and-two-pseudo-instructions.patch (4.21 KB)

0005-Support-for-variable-sized-allocas.patch (10.4 KB)

0006-Test-code.patch (2.67 KB)

0007-Documentation.patch (6.21 KB)

Hi Sanjoy,

The patch generally looks fine except for this part:

diff --git a/lib/CodeGen/StackSegmenter.cpp b/lib/CodeGen/StackSegmenter.cpp
new file mode 100644
index 0000000..5ffb8f2
--- /dev/null
+++ b/lib/CodeGen/StackSegmenter.cpp
@@ -0,0 +1,48 @@
+//===-- StackSegmenter.h - Prolog/Epilog code insertion -------*- C++ -* --===//

The comment is obviously incorrect.

diff --git a/lib/CodeGen/StackSegmenter.h b/lib/CodeGen/StackSegmenter.h
new file mode 100644
index 0000000..1284532
--- /dev/null
+++ b/lib/CodeGen/StackSegmenter.h
@@ -0,0 +1,43 @@
+//===-- StackSegmenter.h - Prolog/Epilog code insertion -------*- C++ -* --===//

Please write comment that clearly indicates what the pass would do.

A bigger question is why is StackSegmenter.{h|cpp} are for? It's empty as far as I can tell.

Evan

Hi!

diff --git a/lib/CodeGen/StackSegmenter.cpp b/lib/CodeGen/StackSegmenter.cpp
new file mode 100644
index 0000000..5ffb8f2
--- /dev/null
+++ b/lib/CodeGen/StackSegmenter.cpp
@@ -0,0 +1,48 @@
+//===-- StackSegmenter.h - Prolog/Epilog code insertion -------*- C++ -* --===//

The comment is obviously incorrect.

Thanks. So much for lifting file headers. :slight_smile:

diff --git a/lib/CodeGen/StackSegmenter.h b/lib/CodeGen/StackSegmenter.h
new file mode 100644
index 0000000..1284532
--- /dev/null
+++ b/lib/CodeGen/StackSegmenter.h
@@ -0,0 +1,43 @@
+//===-- StackSegmenter.h - Prolog/Epilog code insertion -------*- C++ -* --===//

Please write comment that clearly indicates what the pass would do.

Will do.

A bigger question is why is StackSegmenter.{h|cpp} are for? It's empty as far as I can tell.

In the `Prologue code emission for X86.', I modify this pass to emit
segmented stacks code before function prologues (by calling a function
in X86FrameLowering). I organized the code this way since it seemed
more elegant than checking for a flag inside the corresponding
emitPrologue.

According to the patch you send, the pass is not doing anything:

+bool StackSegmenter::runOnMachineFunction(MachineFunction &MF) {
+ return false;
+}

Hi!

According to the patch you send, the pass is not doing anything:

+bool StackSegmenter::runOnMachineFunction(MachineFunction &MF) {
+ return false;
+}
+

It is, in the next patch.

diff --git a/lib/CodeGen/StackSegmenter.cpp b/lib/CodeGen/StackSegmenter.cpp
index 5ffb8f2..cc2ca87 100644
--- a/lib/CodeGen/StackSegmenter.cpp
+++ b/lib/CodeGen/StackSegmenter.cpp
@@ -40,7 +40,10 @@ void StackSegmenter::getAnalysisUsage(AnalysisUsage
&info) const {
}

bool StackSegmenter::runOnMachineFunction(MachineFunction &MF) {
- return false;
+ const TargetFrameLowering &TFI = *MF.getTarget().getFrameLowering();
+ TFI.adjustForSegmentedStacks(MF);
+ // adjustForSegmentedStacks always changes the MachineFunction
+ return true;
}

FunctionPass *llvm::createStackSegmenter() {

Please move it into PEI. It doesn't make sense to add a pass, which has costs, for this.

Evan