glsl2: Move our data from a glsl_shader* on the side to the main gl_shader *.

This saves recompiling at link time.  gl_shader->ir is made a pointer
so that we don't have to bring exec_list into mtypes.h.
diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp
index 85ede3e..c2dde31 100644
--- a/src/mesa/shader/ir_to_mesa.cpp
+++ b/src/mesa/shader/ir_to_mesa.cpp
@@ -1561,13 +1561,12 @@
 }
 
 struct gl_program *
-get_mesa_program(GLcontext *ctx, void *mem_ctx, struct glsl_shader *shader)
+get_mesa_program(GLcontext *ctx, void *mem_ctx, struct gl_shader *shader)
 {
    ir_to_mesa_visitor v;
    struct prog_instruction *mesa_instructions, *mesa_inst;
    ir_instruction **mesa_instruction_annotation;
    int i;
-   exec_list *instructions = &shader->ir;
    struct gl_program *prog;
    GLenum target;
 
@@ -1587,7 +1586,7 @@
    v.prog = prog;
 
    v.mem_ctx = talloc_new(NULL);
-   visit_exec_list(instructions, &v);
+   visit_exec_list(shader->ir, &v);
    v.ir_to_mesa_emit_op1(NULL, OPCODE_END,
 			 ir_to_mesa_undef_dst, ir_to_mesa_undef);
 
@@ -1635,26 +1634,17 @@
    prog->Instructions = mesa_instructions;
    prog->NumInstructions = num_instructions;
 
-   _mesa_reference_program(ctx, &shader->mesa_shader->Program, prog);
+   _mesa_reference_program(ctx, &shader->Program, prog);
 
    return prog;
 }
 
-/* Takes a Mesa gl shader structure and compiles it, returning our Mesa-like
- * structure with the IR and such attached.
- */
-static struct glsl_shader *
-_mesa_get_glsl_shader(GLcontext *ctx, void *mem_ctx, struct gl_shader *sh)
-{
-   struct glsl_shader *shader = talloc_zero(mem_ctx, struct glsl_shader);
-   struct _mesa_glsl_parse_state *state;
+extern "C" {
 
-   shader->Type = sh->Type;
-   shader->Name = sh->Name;
-   shader->RefCount = 1;
-   shader->Source = sh->Source;
-   shader->SourceLen = strlen(sh->Source);
-   shader->mesa_shader = sh;
+void
+_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
+{
+   struct _mesa_glsl_parse_state *state;
 
    state = talloc_zero(shader, struct _mesa_glsl_parse_state);
    switch (shader->Type) {
@@ -1665,7 +1655,7 @@
 
    state->scanner = NULL;
    state->translation_unit.make_empty();
-   state->symbols = new(mem_ctx) glsl_symbol_table;
+   state->symbols = new(shader) glsl_symbol_table;
    state->info_log = talloc_strdup(shader, "");
    state->error = false;
    state->temp_index = 0;
@@ -1686,25 +1676,25 @@
      _mesa_glsl_lexer_dtor(state);
    }
 
-   shader->ir.make_empty();
+   shader->ir = new(shader) exec_list;
    if (!state->error && !state->translation_unit.is_empty())
-      _mesa_ast_to_hir(&shader->ir, state);
+      _mesa_ast_to_hir(shader->ir, state);
 
    /* Optimization passes */
-   if (!state->error && !shader->ir.is_empty()) {
+   if (!state->error && !shader->ir->is_empty()) {
       bool progress;
       do {
 	 progress = false;
 
-	 progress = do_function_inlining(&shader->ir) || progress;
-	 progress = do_if_simplification(&shader->ir) || progress;
-	 progress = do_copy_propagation(&shader->ir) || progress;
-	 progress = do_dead_code_local(&shader->ir) || progress;
-	 progress = do_dead_code_unlinked(state, &shader->ir) || progress;
-	 progress = do_constant_variable_unlinked(&shader->ir) || progress;
-	 progress = do_constant_folding(&shader->ir) || progress;
-	 progress = do_vec_index_to_swizzle(&shader->ir) || progress;
-	 progress = do_swizzle_swizzle(&shader->ir) || progress;
+	 progress = do_function_inlining(shader->ir) || progress;
+	 progress = do_if_simplification(shader->ir) || progress;
+	 progress = do_copy_propagation(shader->ir) || progress;
+	 progress = do_dead_code_local(shader->ir) || progress;
+	 progress = do_dead_code_unlinked(state, shader->ir) || progress;
+	 progress = do_constant_variable_unlinked(shader->ir) || progress;
+	 progress = do_constant_folding(shader->ir) || progress;
+	 progress = do_vec_index_to_swizzle(shader->ir) || progress;
+	 progress = do_swizzle_swizzle(shader->ir) || progress;
       } while (progress);
    }
 
@@ -1714,23 +1704,6 @@
    shader->InfoLog = state->info_log;
 
    talloc_free(state);
-
-   return shader;
-}
-
-extern "C" {
-
-void
-_mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *sh)
-{
-   struct glsl_shader *shader;
-   TALLOC_CTX *mem_ctx = talloc_new(NULL);
-
-   shader = _mesa_get_glsl_shader(ctx, mem_ctx, sh);
-
-   sh->CompileStatus = shader->CompileStatus;
-   sh->InfoLog = strdup(shader->InfoLog);
-   talloc_free(mem_ctx);
  }
 
 void
@@ -1738,18 +1711,16 @@
 {
    struct glsl_program *whole_program;
    unsigned int i;
-
    _mesa_clear_shader_program_data(ctx, prog);
 
    whole_program = talloc_zero(NULL, struct glsl_program);
    whole_program->LinkStatus = GL_TRUE;
    whole_program->NumShaders = prog->NumShaders;
-   whole_program->Shaders = talloc_array(whole_program, struct glsl_shader *,
+   whole_program->Shaders = talloc_array(whole_program, struct gl_shader *,
 					 prog->NumShaders);
 
    for (i = 0; i < prog->NumShaders; i++) {
-      whole_program->Shaders[i] = _mesa_get_glsl_shader(ctx, whole_program,
-							prog->Shaders[i]);
+      whole_program->Shaders[i] = prog->Shaders[i];
       if (!whole_program->Shaders[i]->CompileStatus) {
 	 whole_program->InfoLog =
 	    talloc_asprintf_append(whole_program->InfoLog,
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index a584f60..40b8286 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -44,7 +44,7 @@
 #include "shader/prog_uniform.h"
 #include "shader/shader_api.h"
 #include "shader/uniforms.h"
-
+#include "talloc.h"
 
 /**
  * Allocate a new gl_shader_program object, initialize it.
@@ -253,7 +253,7 @@
 {
    struct gl_shader *shader;
    assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
-   shader = CALLOC_STRUCT(gl_shader);
+   shader = talloc_zero(NULL, struct gl_shader);
    if (shader) {
       shader->Type = type;
       shader->Name = name;
@@ -268,10 +268,8 @@
 {
    if (sh->Source)
       free((void *) sh->Source);
-   if (sh->InfoLog)
-      free(sh->InfoLog);
    _mesa_reference_program(ctx, &sh->Program, NULL);
-   free(sh);
+   talloc_free(sh);
 }