@@ -167,31 +167,29 @@ void setName(jl_codegen_params_t ¶ms, Value *V, const Twine &Name)
167
167
// is not checking that setName is only called for non-folded instructions (e.g. folded bitcasts
168
168
// and 0-byte geps), which can result in information loss on the renamed instruction.
169
169
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)) {
171
171
V->setName (Name);
172
172
}
173
173
}
174
174
175
175
void maybeSetName (jl_codegen_params_t ¶ms, Value *V, const Twine &Name)
176
176
{
177
177
// 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))
179
179
V->setName (Name);
180
- }
181
180
}
182
181
183
182
void setName (jl_codegen_params_t ¶ms, Value *V, std::function<std::string()> GetName)
184
183
{
185
184
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))
187
186
V->setName (Twine (GetName ()));
188
- }
189
187
}
190
188
191
189
void setNameWithField (jl_codegen_params_t ¶ms, Value *V, std::function<StringRef()> GetObjName, jl_datatype_t *jt, unsigned idx, const Twine &suffix)
192
190
{
193
191
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)) {
195
193
if (jl_is_tuple_type (jt)){
196
194
V->setName (Twine (GetObjName ()) + " [" + Twine (idx + 1 ) + " ]" + suffix);
197
195
return ;
@@ -8327,7 +8325,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
8327
8325
if (f == NULL ) {
8328
8326
f = Function::Create (ftype, GlobalVariable::ExternalLinkage, name, M);
8329
8327
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 ) {
8331
8329
ios_t sigbuf;
8332
8330
ios_mem (&sigbuf, 0 );
8333
8331
jl_static_show_func_sig ((JL_STREAM*) &sigbuf, sig);
@@ -8435,7 +8433,7 @@ static jl_llvm_functions_t
8435
8433
std::map<int , BasicBlock*> labels;
8436
8434
ctx.module = jl_is_method (lam->def .method ) ? lam->def .method ->module : lam->def .module ;
8437
8435
ctx.linfo = lam;
8438
- ctx.name = TSM. getModuleUnlocked ()-> getModuleIdentifier (). data ( );
8436
+ ctx.name = name_from_method_instance (lam );
8439
8437
size_t nreq = src->nargs ;
8440
8438
int va = src->isva ;
8441
8439
ctx.nargs = nreq;
@@ -8488,7 +8486,7 @@ static jl_llvm_functions_t
8488
8486
// jl_printf(JL_STDERR, "\n*** compiling %s at %s:%d\n\n",
8489
8487
// jl_symbol_name(ctx.name), ctx.file.str().c_str(), toplineno);
8490
8488
8491
- bool debug_enabled = ctx.emission_context .debug_level != 0 ;
8489
+ bool debug_enabled = ctx.emission_context .params -> debug_info_level != 0 ;
8492
8490
if (dbgFuncName.empty ()) // Should never happen anymore?
8493
8491
debug_enabled = false ;
8494
8492
@@ -8564,15 +8562,14 @@ static jl_llvm_functions_t
8564
8562
// allocate Function declarations and wrapper objects
8565
8563
// Safe because params holds ctx lock
8566
8564
Module *M = TSM.getModuleUnlocked ();
8567
- M->addModuleFlag (Module::Warning, " julia.debug_level" , ctx.emission_context .debug_level );
8568
8565
jl_debugcache_t debugcache;
8569
8566
debugcache.initialize (M);
8570
8567
jl_returninfo_t returninfo = {};
8571
8568
Function *f = NULL ;
8572
8569
bool has_sret = false ;
8573
8570
if (specsig) { // assumes !va and !needsparams
8574
8571
SmallVector<const char *,0 > ArgNames (0 );
8575
- if (ctx. emission_context . debug_level >= 2 ) {
8572
+ if (!M-> getContext (). shouldDiscardValueNames () ) {
8576
8573
ArgNames.resize (ctx.nargs , " " );
8577
8574
for (int i = 0 ; i < ctx.nargs ; i++) {
8578
8575
jl_sym_t *argname = slot_symbol (ctx, i);
@@ -8639,7 +8636,7 @@ static jl_llvm_functions_t
8639
8636
declarations.functionObject = needsparams ? " jl_fptr_sparam" : " jl_fptr_args" ;
8640
8637
}
8641
8638
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) {
8643
8640
ios_t sigbuf;
8644
8641
ios_mem (&sigbuf, 0 );
8645
8642
jl_static_show_func_sig ((JL_STREAM*) &sigbuf, (jl_value_t *)lam->specTypes );
@@ -8694,7 +8691,7 @@ static jl_llvm_functions_t
8694
8691
if (debug_enabled) {
8695
8692
topfile = dbuilder.createFile (ctx.file , " ." );
8696
8693
DISubroutineType *subrty;
8697
- if (ctx.emission_context .debug_level <= 1 )
8694
+ if (ctx.emission_context .params -> debug_info_level <= 1 )
8698
8695
subrty = debugcache.jl_di_func_null_sig ;
8699
8696
else if (!specsig)
8700
8697
subrty = debugcache.jl_di_func_sig ;
@@ -8715,7 +8712,7 @@ static jl_llvm_functions_t
8715
8712
);
8716
8713
topdebugloc = DILocation::get (ctx.builder .getContext (), toplineno, 0 , SP, NULL );
8717
8714
f->setSubprogram (SP);
8718
- if (ctx.emission_context .debug_level >= 2 ) {
8715
+ if (ctx.emission_context .params -> debug_info_level >= 2 ) {
8719
8716
const bool AlwaysPreserve = true ;
8720
8717
// Go over all arguments and local variables and initialize their debug information
8721
8718
for (i = 0 ; i < nreq; i++) {
@@ -10161,7 +10158,7 @@ jl_llvm_functions_t jl_emit_codeinst(
10161
10158
if (// keep code when keeping everything
10162
10159
!(JL_DELETE_NON_INLINEABLE) ||
10163
10160
// 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
10165
10162
jl_options.debug_level > 1 ) {
10166
10163
// update the stored code
10167
10164
if (inferred != (jl_value_t *)src) {
0 commit comments