Illegal symbol with ASM statement, compiling part of the Performance Application Programming Interface (PAPI)

I’m trying to compile the PAPI file validation_tests/instructions_testcode.c using the command

nvc -m64 -tp=native -fpic -noswitcherror -I/usr/local/include -DPOTENTIALLY_UNUSED='' -D__USE_GNU -DPAPI_NUM_COMP=1 -D__aarch64__ -fasm -DUSE_PTHREAD_MUTEXES  -DPAPI_NUM_COMP=3 -O1 -D__aarch64__ -I/usr/local/include  -c -o ../validation_tests/instructions_testcode.o ../validation_tests/instructions_testcode.c

but get this error-message:

nvc-Warning-Unknown switch: -fasm
"../validation_tests/instructions_testcode.c", line 85: warning: statement is unreachable [code_is_unreachable]
    return CODE_UNIMPLEMENTED;
    ^

Remark: individual warnings can be suppressed with "--diag_suppress <warning-name>"

NVC++-F-0040-Illegal use of symbol,  (../validation_tests/instructions_testcode.c: 87)
NVC++/arm Linux 26.5-0: compilation aborted
make[1]: [<builtin>: ../validation_tests/instructions_testcode.o] Error 2 (ignored)

The particular code-snippet is this

      8 int instructions_million(void) {
      9 
     10 #if defined(__i386__) || (defined __x86_64__)
                .......

     72 #elif defined(__aarch64__)
     73         asm(    "       ldr     x2,=333332      // set count\n"
     74                 "55:\n"
     75                 "       add     x2,x2,#-1\n"
     76                 "       cmp     x2,#0\n"
     77                 "       bne     55b             // repeat till zero\n"
     78                 : /* no output registers */
     79                 : /* no inputs */
     80                 : "cc", "r2" /* clobbered */
     81         );
     82         return 0;
     83 #endif
     84 
     85         return CODE_UNIMPLEMENTED;
     86 
     87 }

so I can’t tell how to interpret the “illegal use of symbol” since line 87 only closes the statement.

This is using the latest version of each on ARM64:

NVHPC 26.5
PAPI 7.2.0

Hi Carl,

This looks to be a bug in the source in that “r2” should be “x2” at line 80. “r2” is a x86_64 register while “x2” is aarch64.

Hope this helps,
Mat

Wow! No way I could have caught this myself. I tested the fix and the compilation-error goes away.

I filed a bug with the PAPI developers here: