Changeset 3aeaecd


Ignore:
Timestamp:
Sep 25, 2017, 3:26:03 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
696bf6e
Parents:
f265042
Message:

Reduce the number of unique names generated for argument copy construction

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rf265042 r3aeaecd  
    404404                        result = result->clone();
    405405                        env->apply( result );
    406                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
     406                        ObjectDecl * tmp = ObjectDecl::newObject( "__tmp", result, nullptr );
    407407                        tmp->get_type()->set_const( false );
    408408
     
    418418                                if ( function->get_var()->get_linkage() == LinkageSpec::Intrinsic ) return;
    419419                        }
     420
     421                        // set a unique name for the temporary once it's certain the call is necessary
     422                        tmp->name = tempNamer.newName();
    420423
    421424                        // replace argument to function call with temporary
     
    447450                                result = result->clone();
    448451                                env->apply( result );
    449                                 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
     452                                ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
    450453                                ret->get_type()->set_const( false );
    451454                                impCpCtorExpr->get_returnDecls().push_back( ret );
    452455                                CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; )
    453456                                if ( ! dynamic_cast< ReferenceType * >( result ) ) {
    454                                         // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
     457                                        // destructing reference returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary
    455458                                        destructRet( ret, impCpCtorExpr );
    456459                                }
     
    469472                                result = result->clone();
    470473                                env->apply( result );
    471                                 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 );
     474                                ObjectDecl * ret = ObjectDecl::newObject( retNamer.newName(), result, nullptr );
    472475                                ret->get_type()->set_const( false );
    473476                                stmtExpr->get_returnDecls().push_front( ret );
     
    506509                        } else {
    507510                                // expr isn't a call expr, so create a new temporary variable to use to hold the value of the unique expression
    508                                 unqExpr->set_object( new ObjectDecl( toString("_unq", unqExpr->get_id()), Type::StorageClasses(), LinkageSpec::C, nullptr, unqExpr->get_result()->clone(), nullptr ) );
     511                                unqExpr->set_object( ObjectDecl::newObject( toString("_unq", unqExpr->get_id()), unqExpr->get_result()->clone(), nullptr ) );
    509512                                unqExpr->set_var( new VariableExpr( unqExpr->get_object() ) );
    510513                        }
     
    11491152
    11501153                        // xxx - ideally we would reuse the temporary generated from the copy constructor passes from within firstArg if it exists and not generate a temporary if it's unnecessary.
    1151                         ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, nullptr, ctorExpr->get_result()->clone(), nullptr );
     1154                        ObjectDecl * tmp = ObjectDecl::newObject( tempNamer.newName(), ctorExpr->get_result()->clone(), nullptr );
    11521155                        addDeclaration( tmp );
    11531156
  • src/tests/.expect/sched-ext-parse.txt

    rf265042 r3aeaecd  
    10551055static inline struct condition ___operator_assign__F10scondition_R10scondition10scondition_autogen___1(struct condition *___dst__R10scondition_1, struct condition ___src__10scondition_1){
    10561056    struct condition ___ret__10scondition_1;
    1057     struct __condition_blocked_queue_t _tmp_cp56;
     1057    struct __condition_blocked_queue_t _tmp_cp4;
    10581058    struct __condition_blocked_queue_t _tmp_cp_ret29;
    1059     ((void)(((void)(_tmp_cp_ret29=___operator_assign__F28s__condition_blocked_queue_t_R28s__condition_blocked_queue_t28s__condition_blocked_queue_t_autogen___1((&(*___dst__R10scondition_1).__blocked__28s__condition_blocked_queue_t_1), (((void)___constructor__F_R28s__condition_blocked_queue_t28s__condition_blocked_queue_t_autogen___1((&_tmp_cp56), ___src__10scondition_1.__blocked__28s__condition_blocked_queue_t_1)) , _tmp_cp56)))) , _tmp_cp_ret29));
     1059    ((void)(((void)(_tmp_cp_ret29=___operator_assign__F28s__condition_blocked_queue_t_R28s__condition_blocked_queue_t28s__condition_blocked_queue_t_autogen___1((&(*___dst__R10scondition_1).__blocked__28s__condition_blocked_queue_t_1), (((void)___constructor__F_R28s__condition_blocked_queue_t28s__condition_blocked_queue_t_autogen___1((&_tmp_cp4), ___src__10scondition_1.__blocked__28s__condition_blocked_queue_t_1)) , _tmp_cp4)))) , _tmp_cp_ret29));
    10601060    ((void)___destructor__F_R28s__condition_blocked_queue_t_autogen___1((&_tmp_cp_ret29)));
    1061     ((void)___destructor__F_R28s__condition_blocked_queue_t_autogen___1((&_tmp_cp56)));
     1061    ((void)___destructor__F_R28s__condition_blocked_queue_t_autogen___1((&_tmp_cp4)));
    10621062    ((void)((*___dst__R10scondition_1).__monitors__PP13smonitor_desc_1=___src__10scondition_1.__monitors__PP13smonitor_desc_1));
    10631063    ((void)((*___dst__R10scondition_1).__monitor_count__Us_1=___src__10scondition_1.__monitor_count__Us_1));
     
    11551155static inline struct M ___operator_assign__F2sM_R2sM2sM_autogen___1(struct M *___dst__R2sM_1, struct M ___src__2sM_1){
    11561156    struct M ___ret__2sM_1;
    1157     struct monitor_desc _tmp_cp60;
     1157    struct monitor_desc _tmp_cp5;
    11581158    struct monitor_desc _tmp_cp_ret31;
    1159     ((void)(((void)(_tmp_cp_ret31=___operator_assign__F13smonitor_desc_R13smonitor_desc13smonitor_desc_autogen___1((&(*___dst__R2sM_1).____mon__13smonitor_desc_1), (((void)___constructor__F_R13smonitor_desc13smonitor_desc_autogen___1((&_tmp_cp60), ___src__2sM_1.____mon__13smonitor_desc_1)) , _tmp_cp60)))) , _tmp_cp_ret31));
     1159    ((void)(((void)(_tmp_cp_ret31=___operator_assign__F13smonitor_desc_R13smonitor_desc13smonitor_desc_autogen___1((&(*___dst__R2sM_1).____mon__13smonitor_desc_1), (((void)___constructor__F_R13smonitor_desc13smonitor_desc_autogen___1((&_tmp_cp5), ___src__2sM_1.____mon__13smonitor_desc_1)) , _tmp_cp5)))) , _tmp_cp_ret31));
    11601160    ((void)___destructor__F_R13smonitor_desc_autogen___1((&_tmp_cp_ret31)));
    1161     ((void)___destructor__F_R13smonitor_desc_autogen___1((&_tmp_cp60)));
     1161    ((void)___destructor__F_R13smonitor_desc_autogen___1((&_tmp_cp5)));
    11621162    ((void)___constructor__F_R2sM2sM_autogen___1((&___ret__2sM_1), ___src__2sM_1));
    11631163    return ((struct M )___ret__2sM_1);
Note: See TracChangeset for help on using the changeset viewer.