SourceryTools / nvptx-tools

nvptx-tools: a collection of tools for use with nvptx-none GCC toolchains.
https://gcc.gnu.org/wiki/nvptx
46 stars 10 forks source link

nvptx-as reorders ".file" directives #20

Open tschwinge opened 7 years ago

tschwinge commented 7 years ago

While filing https://gcc.gnu.org/PR82202, I noticed that nvptx-as reorders .file directives, for example compiling libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c with -fopenacc -O2 -foffload=nvptx-none='-save-temps -g' we got:

$ [...]/nvptx-none-as -o ccfEmvMv.s_ ccfEmvMv.s
$ diff -uw ccfEmvMv.s ccfEmvMv.s_
[...]
 // BEGIN FUNCTION DECL: main$_omp_fn$0
 .entry main$_omp_fn$0 (.param.u64 %in_ar0);
-
+.file 1 "source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c"
 // BEGIN FUNCTION DEF: main$_omp_fn$0
 .entry main$_omp_fn$0 (.param.u64 %in_ar0)
 {
@@ -46,7 +44,6 @@
        @%r54   bra     $L7;
                mov.u64 %r37, %ar0;
                mov.u32 %r36, %ctaid.x;
-       .file 1 "source-gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/loop-g-1.c"
        .loc 1 20 0
                shl.b32 %r39, %r36, 10;
                add.u32 %r40, %r39, %r36;

I don't think this is intentional?

tschwinge commented 3 years ago

This behavior got implemented in commit bd12880f83fe393d66229ae7ed34236cd7645f23 "Deal with .file and .loc directives".

I'll asume that the reason lies in PTX 3.1, 10.5 DEBUGGING DIRECTIVES, Table 162. Debugging Directives: .file stating that "The .file directive is allowed only in the outermost scope".

So, the reordering of .file directives seems to be intentional, after all. But, it needs to be documented properly.