Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TishSerg opened this issue Oct 3, 2019 · 26 comments
Closed

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

TishSerg opened this issue Oct 3, 2019 · 26 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Milestone

Comments

@TishSerg
Copy link

TishSerg commented Oct 3, 2019

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

@sean-mcmanus
Copy link
Collaborator

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).

@cardiffman
Copy link

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.

@sean-mcmanus
Copy link
Collaborator

@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

@cardiffman
Copy link

@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.

@guillep2k
Copy link

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" );

@Prehistoricman
Copy link

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.

@sean-mcmanus
Copy link
Collaborator

I think the VS issue at https://developercommunity.visualstudio.com/content/problem/778258/cc-intellisense-shows-unknown-register-name-with-a.html may need more upvotes.

@attzonko
Copy link

attzonko commented Feb 23, 2021

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

@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 1.3.0 Mar 11, 2021
@sean-mcmanus sean-mcmanus modified the milestones: 1.3.0, Tracking Mar 11, 2021
@sean-mcmanus sean-mcmanus added the more votes needed Issues that have been postponed until more community members upvote it label Jun 3, 2021
@guillep2k
Copy link

@RSDuck, as you've created #5381, would you mind upvoting this issue? (it's marked as "more votes needed").

@Prehistoricman
Copy link

The Visual Studio issue has been marked as fixed, but as of C/C++ v1.5.1 I am still seeing the issue. Can someone see if it is fixed in Visual Studio?

@guillep2k
Copy link

The Visual Studio issue has been marked as fixed, but as of C/C++ v1.5.1 I am still seeing the issue. Can someone see if it is fixed in Visual Studio?

Perhaps in VS 2022 beta?

@sean-mcmanus
Copy link
Collaborator

@Prehistoricman It was never fixed. Someone just assigned it the wrong state temporarily. The issue got closed as low priority, but we're still tracking the issue internally and you can upvote this GitHub issue.

@Victor333Huesca
Copy link

Any updates on this issue? Is it still tracked and planned in a future release?

@tigert1998
Copy link

avx2 registers like "ymm0" also fails to be recognized.

@sean-mcmanus
Copy link
Collaborator

@Victor333Huesca It was closed as "low priority" by the VS team. I'm looking into if we can get it re-activated due to our larger number of embedded users and higher upvote count.

@beaver700nh
Copy link

I'm on Arduino and I'm also getting this, but for pgm_read_word_near() which causes the error "unknown register name 'r0'"

@sean-mcmanus
Copy link
Collaborator

FYI, I've opened an internal VS issue to track this and mentioned the 12 upvotes.

@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 1.11.1 Jun 20, 2022
@sean-mcmanus sean-mcmanus removed the more votes needed Issues that have been postponed until more community members upvote it label Jun 20, 2022
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Jun 22, 2022
@tehKaiN
Copy link

tehKaiN commented Jun 25, 2022

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

@sean-mcmanus
Copy link
Collaborator

@tehKaiN The fix will work for all architectures.

@sean-mcmanus
Copy link
Collaborator

This fix is available with 1.11.2 (pre-release): https://github.com/microsoft/vscode-cpptools/releases

@tehKaiN
Copy link

tehKaiN commented Jul 22, 2022

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?

@sean-mcmanus
Copy link
Collaborator

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

@sean-mcmanus
Copy link
Collaborator

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

@Victor333Huesca
Copy link

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.

@sean-mcmanus
Copy link
Collaborator

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

@sean-mcmanus
Copy link
Collaborator

@tehKaiN @Victor333Huesca The register declaration issue is fixed with 1.12.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.12.0

@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

10 participants