@@ -167,31 +167,29 @@ void setName(jl_codegen_params_t ¶ms, Value *V, const Twine &Name)
167167    //  is not checking that setName is only called for non-folded instructions (e.g. folded bitcasts
168168    //  and 0-byte geps), which can result in information loss on the renamed instruction.
169169    assert ((isa<Constant>(V) || isa<Instruction>(V)) && " Should only set names on instructions!" 
170-     if  (params. debug_level  >=  2  &&  !isa<Constant>(V)) {
170+     if  (!isa<Constant>(V)) {
171171        V->setName (Name);
172172    }
173173}
174174
175175void  maybeSetName (jl_codegen_params_t  ¶ms, Value *V, const  Twine &Name)
176176{
177177    //  To be used when we may get an Instruction or something that is not an instruction i.e Constants/Arguments
178-     if  (params. debug_level  >=  2  &&  isa<Instruction>(V)) { 
178+     if  (isa<Instruction>(V))
179179        V->setName (Name);
180-     }
181180}
182181
183182void  setName (jl_codegen_params_t  ¶ms, Value *V, std::function<std::string()> GetName)
184183{
185184    assert ((isa<Constant>(V) || isa<Instruction>(V)) && " Should only set names on instructions!" 
186-     if  (params.debug_level  >=  2   && !isa<Constant>(V)) { 
185+     if  (! params.getContext (). shouldDiscardValueNames ()  && !isa<Constant>(V))
187186        V->setName (Twine (GetName ()));
188-     }
189187}
190188
191189void  setNameWithField (jl_codegen_params_t  ¶ms, Value *V, std::function<StringRef()> GetObjName, jl_datatype_t *jt, unsigned idx, const  Twine &suffix)
192190{
193191    assert ((isa<Constant>(V) || isa<Instruction>(V)) && " Should only set names on instructions!" 
194-     if  (params.debug_level  >=  2  && !isa<Constant>(V)) {
192+     if  (! params.getContext (). shouldDiscardValueNames ()  && !isa<Constant>(V)) {
195193        if  (jl_is_tuple_type (jt)){
196194            V->setName (Twine (GetObjName ()) + " [" Twine (idx + 1 ) + " ]" 
197195            return ;
@@ -8327,7 +8325,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
83278325        if  (f == NULL ) {
83288326            f = Function::Create (ftype, GlobalVariable::ExternalLinkage, name, M);
83298327            jl_init_function (f, ctx.emission_context .TargetTriple );
8330-             if  (ctx.emission_context .debug_level  >= 2 ) {
8328+             if  (ctx.emission_context .params -> debug_info_level  >= 2 ) {
83318329                ios_t  sigbuf;
83328330                ios_mem (&sigbuf, 0 );
83338331                jl_static_show_func_sig ((JL_STREAM*) &sigbuf, sig);
@@ -8435,7 +8433,7 @@ static jl_llvm_functions_t
84358433    std::map<int , BasicBlock*> labels;
84368434    ctx.module  = jl_is_method (lam->def .method ) ? lam->def .method ->module  : lam->def .module ;
84378435    ctx.linfo  = lam;
8438-     ctx.name  = TSM. getModuleUnlocked ()-> getModuleIdentifier (). data ( );
8436+     ctx.name  = name_from_method_instance (lam );
84398437    size_t  nreq = src->nargs ;
84408438    int  va = src->isva ;
84418439    ctx.nargs  = nreq;
@@ -8488,7 +8486,7 @@ static jl_llvm_functions_t
84888486    //  jl_printf(JL_STDERR, "\n*** compiling %s at %s:%d\n\n",
84898487    //            jl_symbol_name(ctx.name), ctx.file.str().c_str(), toplineno);
84908488
8491-     bool  debug_enabled = ctx.emission_context .debug_level  != 0 ;
8489+     bool  debug_enabled = ctx.emission_context .params -> debug_info_level  != 0 ;
84928490    if  (dbgFuncName.empty ()) //  Should never happen anymore?
84938491        debug_enabled = false ;
84948492
@@ -8564,15 +8562,14 @@ static jl_llvm_functions_t
85648562    //  allocate Function declarations and wrapper objects
85658563    // Safe because params holds ctx lock
85668564    Module *M = TSM.getModuleUnlocked ();
8567-     M->addModuleFlag (Module::Warning, " julia.debug_level" emission_context .debug_level );
85688565    jl_debugcache_t  debugcache;
85698566    debugcache.initialize (M);
85708567    jl_returninfo_t  returninfo = {};
85718568    Function *f = NULL ;
85728569    bool  has_sret = false ;
85738570    if  (specsig) { //  assumes !va and !needsparams
85748571        SmallVector<const  char *,0 > ArgNames (0 );
8575-         if  (ctx. emission_context . debug_level  >=  2 ) {
8572+         if  (!M-> getContext (). shouldDiscardValueNames () ) {
85768573            ArgNames.resize (ctx.nargs , " " 
85778574            for  (int  i = 0 ; i < ctx.nargs ; i++) {
85788575                jl_sym_t  *argname = slot_symbol (ctx, i);
@@ -8639,7 +8636,7 @@ static jl_llvm_functions_t
86398636        declarations.functionObject  = needsparams ? " jl_fptr_sparam" " jl_fptr_args" 
86408637    }
86418638
8642-     if  (ctx.emission_context .debug_level  >= 2  && lam->def .method  && jl_is_method (lam->def .method ) && lam->specTypes  != (jl_value_t *)jl_emptytuple_type) {
8639+     if  (!params. getContext (). shouldDiscardValueNames () &&  ctx.emission_context .params -> debug_info_level  >= 2  && lam->def .method  && jl_is_method (lam->def .method ) && lam->specTypes  != (jl_value_t *)jl_emptytuple_type) {
86438640        ios_t  sigbuf;
86448641        ios_mem (&sigbuf, 0 );
86458642        jl_static_show_func_sig ((JL_STREAM*) &sigbuf, (jl_value_t *)lam->specTypes );
@@ -8694,7 +8691,7 @@ static jl_llvm_functions_t
86948691    if  (debug_enabled) {
86958692        topfile = dbuilder.createFile (ctx.file , " ." 
86968693        DISubroutineType *subrty;
8697-         if  (ctx.emission_context .debug_level  <= 1 )
8694+         if  (ctx.emission_context .params -> debug_info_level  <= 1 )
86988695            subrty = debugcache.jl_di_func_null_sig ;
86998696        else  if  (!specsig)
87008697            subrty = debugcache.jl_di_func_sig ;
@@ -8715,7 +8712,7 @@ static jl_llvm_functions_t
87158712                                     );
87168713        topdebugloc = DILocation::get (ctx.builder .getContext (), toplineno, 0 , SP, NULL );
87178714        f->setSubprogram (SP);
8718-         if  (ctx.emission_context .debug_level  >= 2 ) {
8715+         if  (ctx.emission_context .params -> debug_info_level  >= 2 ) {
87198716            const  bool  AlwaysPreserve = true ;
87208717            //  Go over all arguments and local variables and initialize their debug information
87218718            for  (i = 0 ; i < nreq; i++) {
@@ -10161,7 +10158,7 @@ jl_llvm_functions_t jl_emit_codeinst(
1016110158            if  (//  keep code when keeping everything
1016210159                !(JL_DELETE_NON_INLINEABLE) ||
1016310160                //  aggressively keep code when debugging level >= 2
10164-                 //  note that this uses the global jl_options.debug_level, not the local emission_ctx.debug_level 
10161+                 //  note that this uses the global jl_options.debug_level, not the local emission_ctx.debug_info_level 
1016510162                jl_options.debug_level  > 1 ) {
1016610163                //  update the stored code
1016710164                if  (inferred != (jl_value_t *)src) {
0 commit comments