[llvm-commits] [dragonegg] r110550 - /dragonegg/trunk/llvm-backend.cpp

Duncan Sands baldrick at free.fr
Sun Aug 8 08:52:16 PDT 2010


Author: baldrick
Date: Sun Aug  8 10:52:16 2010
New Revision: 110550

URL: http://llvm.org/viewvc/llvm-project?rev=110550&view=rev
Log:
OMP expansion generates new functions that need to be converted to SSA
form before they hit the gimple to LLVM conversion logic.  This is taken
care of in gcc by pass_all_early_optimizations, which bumps the cgraph
state appropriately.  We turn off that pass, so we need to poke the cgraph
state ourselves.  This fixes PR7805.

Modified:
    dragonegg/trunk/llvm-backend.cpp

Modified: dragonegg/trunk/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=110550&r1=110549&r2=110550&view=diff
==============================================================================
--- dragonegg/trunk/llvm-backend.cpp (original)
+++ dragonegg/trunk/llvm-backend.cpp Sun Aug  8 10:52:16 2010
@@ -2251,9 +2251,7 @@
 
 
 /// gate_null - Gate method for a pass that does nothing.
-static bool
-gate_null (void)
-{
+static bool gate_null (void) {
   return false;
 }
 
@@ -2277,6 +2275,40 @@
     }
 };
 
+/// execute_correct_state - Correct the cgraph state to ensure that newly
+/// inserted functions are processed before being converted to LLVM IR.
+static unsigned int execute_correct_state (void) {
+  if (cgraph_state < CGRAPH_STATE_IPA_SSA)
+    cgraph_state = CGRAPH_STATE_IPA_SSA;
+  return 0;
+}
+
+/// gate_correct_state - Gate method for pass_gimple_correct_state.
+static bool gate_correct_state (void) {
+  return true;
+}
+
+/// pass_gimple_correct_state - Gimple pass that corrects the cgraph state so
+/// newly inserted functions are processed before being converted to LLVM IR.
+static struct gimple_opt_pass pass_gimple_correct_state =
+{
+    {
+      GIMPLE_PASS,
+      "*gimple_correct_state",	/* name */
+      gate_correct_state,	/* gate */
+      execute_correct_state,	/* execute */
+      NULL,			/* sub */
+      NULL,			/* next */
+      0,			/* static_pass_number */
+      TV_NONE,			/* tv_id */
+      0,			/* properties_required */
+      0,			/* properties_provided */
+      0,			/* properties_destroyed */
+      0,			/* todo_flags_start */
+      0				/* todo_flags_finish */
+    }
+};
+
 /// pass_ipa_null - IPA pass that does nothing.
 static struct ipa_opt_pass_d pass_ipa_null = {
     {
@@ -2489,6 +2521,15 @@
     // lowering fails since immediates have not been propagated into builtin
     // callsites.
 
+    // Insert a pass that ensures that any newly inserted functions, for example
+    // those generated by OMP expansion, are processed before being converted to
+    // LLVM IR.
+    pass_info.pass = &pass_gimple_correct_state.pass;
+    pass_info.reference_pass_name = "early_optimizations";
+    pass_info.ref_pass_instance_number = 1;
+    pass_info.pos_op = PASS_POS_INSERT_BEFORE;
+    register_callback (plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &pass_info);
+
     // Turn off pass_early_local_passes::pass_all_early_optimizations.
     pass_info.pass = &pass_gimple_null.pass;
     pass_info.reference_pass_name = "early_optimizations";





More information about the llvm-commits mailing list