This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/11807] GCC should error out when clobering the stack pointer or frame pointer
- From: "falk at debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Nov 2003 11:49:12 -0000
- Subject: [Bug inline-asm/11807] GCC should error out when clobering the stack pointer or frame pointer
- References: <20030805124527.11807.aw11@os.inf.tu-dresden.de>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From falk at debian dot org 2003-11-17 11:49 -------
Here's what I think:
1. No way we can support clobbering both SP and FP.
2. We could support clobbering the FP by pushing it onto the stack and restoring
it. Doesn't seem worth the trouble, though, since people can do this
themselves in the asm.
3. We could support clobbering the SP by introducing a FP and being very
careful. I cannot see any useful application though, so it doesn't seem
worth the trouble.
So I suggest a patch like this:
--- stmt.c~ 2003-11-16 04:25:28.000000000 +0100
+++ stmt.c 2003-11-17 12:21:24.000000000 +0100
@@ -1524,13 +1524,17 @@
/* Mark clobbered registers. */
if (i >= 0)
{
- /* Clobbering the PIC register is an error */
- if (i == (int) PIC_OFFSET_TABLE_REGNUM)
- {
- error ("PIC register `%s' clobbered in `asm'", regname);
- return;
- }
-
+ switch (i) {
+ case PIC_OFFSET_TABLE_REGNUM:
+ error ("PIC register `%s' clobbered in `asm'", regname);
+ return;
+ case STACK_POINTER_REGNUM:
+ error ("Stack pointer register `%s' clobbered in `asm'", regname);
+ return;
+ case HARD_FRAME_POINTER_REGNUM:
+ error ("Frame pointer register `%s' clobbered in `asm'", regname);
+ return;
+ }
SET_HARD_REG_BIT (clobbered_regs, i);
}
}
I have no time to test it currently, though.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11807