Skip to content

Commit a58ad38

Browse files
committed
Update for no return routine generation support
1 parent aea2477 commit a58ad38

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

tools/flang2/docs/xflag.n

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5239,6 +5239,8 @@ Print array assignments using pointer arithmetic always.
52395239
Don't demote address KMUL operations
52405240
.XB 0x200000:
52415241
in LLVM output, don't output the instruction info (lilix index, opcode)
5242+
.XB 0x400000:
5243+
reserved
52425244

52435245
.XF "202:"
52445246
Set number of bigbuffers for multi-buffer memory management for AMD GPU.

tools/flang2/flang2exe/ll_write.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ ll_write_instruction(FILE *out, LL_Instruction *inst, LL_Module *module, int no_
482482
render_bitcast(out, inst);
483483
break;
484484
case LL_RET:
485-
if (no_return)
486-
fprintf(out, "%scall void @llvm.nvvm.exit()",SPACES);
485+
if (no_return) {
486+
fprintf(out, "%scall void @llvm.nvvm.exit()\n",SPACES);
487+
fprintf(out, "%sunreachable",SPACES);
488+
}
487489
else
488490
fprintf(out, "%sret %s %s", SPACES, inst->operands[0]->type_struct->str,
489491
inst->operands[0]->data);
@@ -726,16 +728,15 @@ ll_write_local_objects(FILE *out, LL_Function *function)
726728
}
727729
}
728730
void
729-
ll_write_function(FILE *out, LL_Function *function, LL_Module *module, int no_return)
731+
ll_write_function(FILE *out, LL_Function *function, LL_Module *module, bool no_return, const char *prefix)
730732
{
731733
int i;
732734
char attribute[256];
733735
LL_BasicBlock *block = function->first;
734736

735737
fprintf(out, "define %s %s %s ", ll_get_linkage_string(function->linkage),
736738
function->calling_convention, function->return_type->str);
737-
fprintf(out, "@%s%s(", no_return?"__no_return_":"",
738-
function->name);
739+
fprintf(out, "@%s%s(", prefix, function->name);
739740
for (i = 0; i < function->num_args; i++) {
740741
fputs(function->arguments[i]->type_struct->str, out);
741742

@@ -2159,7 +2160,7 @@ ll_write_global_objects(FILE *out, LLVMModuleRef module)
21592160
}
21602161

21612162
void
2162-
ll_write_module(FILE *out, LL_Module *module, int generate_no_return_variants)
2163+
ll_write_module(FILE *out, LL_Module *module, int generate_no_return_variants, const char *no_return_prefix)
21632164
{
21642165
int i, j, met_idx;
21652166
LL_Function *function = module->first;
@@ -2274,9 +2275,9 @@ ll_write_module(FILE *out, LL_Module *module, int generate_no_return_variants)
22742275
}
22752276
num_functions = 0;
22762277
while (function) {
2277-
ll_write_function(out, function, module, 0);
2278+
ll_write_function(out, function, module, false, "");
22782279
if (generate_no_return_variants) {
2279-
ll_write_function(out, function, module, 1);
2280+
ll_write_function(out, function, module, true, no_return_prefix);
22802281
}
22812282
function = function->next;
22822283
num_functions++;

tools/flang2/flang2exe/ll_write.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ void ll_write_basicblock(FILE *out, LL_Function *function, LL_BasicBlock *block,
3030
/**
3131
\brief ...
3232
*/
33-
void ll_write_function(FILE *out, LL_Function *function, LL_Module *module,
34-
int no_return);
33+
void ll_write_function(FILE *out, LL_Function *function, LL_Module *module,
34+
bool no_return, const char *prefix);
3535

3636
/**
3737
\brief ...
@@ -72,7 +72,8 @@ void ll_write_metadata(FILE *out, LLVMModuleRef module);
7272
/**
7373
\brief ...
7474
*/
75-
void ll_write_module(FILE *out, LL_Module *module, int no_return);
75+
void ll_write_module(FILE *out, LL_Module *module, int no_return,
76+
const char *no_return_prefix);
7677

7778
/**
7879
\brief ...

0 commit comments

Comments
 (0)