Skip to content

AArch inline asm: "unknown register name" clobber list #4382

Closed

Description

@TishSerg

Type: LanguageService

The bug

  • OS and Version:
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic

$ uname -a
Linux serg-VM 4.15.0-64-generic #73-Ubuntu SMP Thu Sep 12 13:16:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • VS Code Version:
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:30:08.229Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-64-generic
  • C/C++ Extension Version: 0.25.1 (problem exist in v0.23.1 too)
  • No other extensions are installed
  • AArch-specific (ARM) register names aren't recognized in the clobber list of inline asm statement. Nevertheless the code successfully compiles and works.

To Reproduce

  1. Go to any C function body.
  2. Paste asm("mov w0, #0":::"r0");
  3. See error

Expected behavior
AArch-specific register names must be recognized just like x86's eax, rax and so.

Screenshots
image

Activity

  1. sean-mcmanus commented on Oct 15, 2019

    @sean-mcmanus
    Contributor

    Thanks for reporting this. I reported it to the VS team at https://developercommunity.visualstudio.com/content/problem/778258/cc-intellisense-shows-unknown-register-name-with-a.html .

    It's possible we may also need to add support for ARM IntelliSense mode and -std=gnu11 for all the errors to disappear (we have other issues tracking those).

  2. cardiffman commented on May 1, 2020

    @cardiffman

    During WFH about half the developers I work with have been using VSCode and the other half don't use GUI IDEs. A few of us do Linux kernel module development for ARM and MIPS. There is a macro called get_user that obtains one scalar value from user space, and on ARM it expands to inline assembly referencing r0. Every file that has a get_user macro in gets tagged as a problem.

  3. sean-mcmanus commented on May 1, 2020

    @sean-mcmanus
    Contributor

    cardiffman (@cardiffman) If you can edit the macro, you may be able to avoid the errors via surrounding the code in a

    #ifndef __INTELLISENSE__
    // code we don't handle correctly
    #endif
    
  4. cardiffman commented on May 1, 2020

    @cardiffman

    cardiffman (@cardiffman) If you can edit the macro, you may be able to avoid the errors via surrounding the code in a

    #ifndef __INTELLISENSE__
    // code we don't handle correctly
    #endif
    

    Interesting idea. It makes sense that you would have a macro defined to help with that.

  5. guillep2k commented on May 27, 2020

    @guillep2k

    Happens the same with ARM7:

    cpptools version: 0.28.1

    VSCode version:

    Version: 1.45.1 (system setup)
    Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
    Date: 2020-05-14T08:27:35.169Z
    Electron: 7.2.4
    Chrome: 78.0.3904.130
    Node.js: 12.8.1
    V8: 7.8.279.23-electron.0
    OS: Windows_NT x64 10.0.18363
    
    gcc --version
    gcc (GCC) 4.0.1 (WinARM)
    
    "C_Cpp.default.compilerArgs": [ "-mcpu=arm7tdmi" ]
    

    Snippets:

    // Simply declaring a variable triggers the error
    register int r0 asm("r0");
    

    Or declaring registers in the clobber section:

    asm volatile (
    	"mov		ip, %[p1]\n\t"
    	[... some mode code ...]
    	: /* output */
    	: /* input */	[p1]  "r" (portdata)
    	: /* clobber */ "r0", "r1", "r2", "r3", "r4", "ip" );
    
  6. Prehistoricman commented on Nov 6, 2020

    @Prehistoricman

    image

    Same issue - I included "eax" just for demonstration. I would have thought that changing intelliSenseMode to "gcc-arm" would fix this. Intellisense is only recognising x86 registers.

  7. sean-mcmanus commented on Nov 6, 2020

    @sean-mcmanus
    Contributor
  8. attzonko commented on Feb 23, 2021

    @attzonko

    I see the same issue when trying to access ARM registers:
    image

    Here is the example from the arm docs with exactly the same register:
    image

  9. 15 remaining items

  10. tehKaiN commented on Jun 25, 2022

    @tehKaiN

    Hi,

    I have similar problem, but not in ARM GCC compiler, but in Motorola 68000 one. I see this issue is marked as "Done" in 1.11 - is the fix applicable for ARM only, or does it fix the root of the problem for other architectures too?

    obraz

  11. sean-mcmanus commented on Jun 27, 2022

    @sean-mcmanus
    Contributor

    KaiN (@tehKaiN) The fix will work for all architectures.

  12. sean-mcmanus commented on Jul 8, 2022

    @sean-mcmanus
    Contributor
  13. tehKaiN commented on Jul 22, 2022

    @tehKaiN

    unfortunately this doesn't work for me under 1.11.4, screenshot taken just now:

    obraz

    same thing with __asm__ directive instead of __asm, albeit it formats the register string way nicer.

    obraz

    I'm using ms-vscode.cpptools, ms-vscode.cmake-tools and 68000 GCC compiler bundled with bartmanabyss.amiga-debug extension. I understand that you may not want to set up such exotic configuration - can you give me any pointers on how can I find the point of failure for you?

  14. sean-mcmanus commented on Jul 22, 2022

    @sean-mcmanus
    Contributor

    KaiN (@tehKaiN) Sorry about that -- looks like the "asm("mov w0, #0":::"r0");" case got fixed but not the other case.

  15. sean-mcmanus commented on Jul 22, 2022

    @sean-mcmanus
    Contributor

    KaiN (@tehKaiN) I've opened a new issue to track that case: #9627

  16. Victor333Huesca commented on Jul 22, 2022

    @Victor333Huesca

    Yes, I do confirm that the inline asm is fixed with arm, thanks!
    But, the asm register is still reporting an error on my side too.

    PS: I upvoted the new issue.

  17. sean-mcmanus commented on Jul 22, 2022

    @sean-mcmanus
    Contributor

    Victor (@Victor333Huesca) Yes, the error wasn't fixed for register declarations -- we have a potential fix for our next pre-release, pending code review.

  18. locked and limited conversation to collaborators on Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceVisual StudioInherited from Visual StudiobugfixedCheck the Milestone for the release in which the fix is or will be available.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions