git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH maint-1.6.5 v2] block-sha1: avoid pointer conversion that violates alignment constraints

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 15, 2012, 21:27 UTC
Message-ID
<20120715212731.GG1986@burratino>
In-Reply-To
<FDFB73BB-64E8-48F8-95DB-94C0EC7FFB2A@orcon.net.nz>
Hi,
Michael Cree wrote:
> On 15/07/2012, at 8:50 AM, Jonathan Nieder wrote:
Show 5 quoted lines
>>                   gcc takes full advantage by converting the get_be32
>> calls back to a load and bswap and producing a whole bunch of
>> unaligned access traps.
>
> Alpha does not have a bswap (or similar) instruction.
[...]
Show 7 quoted lines
>                                    .  If the pointer is unaligned
> then two neighbouring aligned 32bit loads are required to ensure
> that all four bytes are loaded.  If the pointer is aligned then a
> single 32bit load gets all the four bytes.  Having never looked at
> the generated assembler code, I nevertheless suspect that is the
> guts of the optimisation --- the compiler can eliminate an access to
> memory if it knows the pointer is aligned.
How about:
	gcc takes full advantage by using a single 32-bit load,
	resulting in a whole bunch of unaligned access traps.

You can see the generated assembler with "make block-sha1/sha1.s" and reading the resulting sha1.s file in the current working directory (oops). I don't have an alpha cross-compiler installed or access to an alpha to check for myself.

-- >8 --
Subject: Makefile: fix location of listing produced by "make subdir/foo.s"

When I invoke "make block-sha1/sha1.s", 'make' runs $(CC) -S without specifying where it should put its output and the output ends up in ./sha1.s. Confusing.

Add an -o option to the .s rule to fix this. We were already doing that for most compiler invocations but had forgotten it for the assembler listings.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Thanks,
Jonathan
 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index dc709029..e8d2798f 100644
--- a/Makefile
+++ b/Makefile
@@ -2230,7 +2230,7 @@ $(ASM_OBJ): %.o: %.S GIT-CFLAGS $(missing_dep_dirs)
 endif
 
 %.s: %.c GIT-CFLAGS FORCE
-	$(QUIET_CC)$(CC) -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
+	$(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
 
 ifdef USE_COMPUTED_HEADER_DEPENDENCIES
 # Take advantage of gcc's on-the-fly dependency generation
-- 
1.7.10.4
Previous: Michael CreeNext: Michael Cree
Message 9 of 10 in “block-sha1: avoid unaligned accesses on some big-endian systems”
  1. block-sha1: avoid unaligned accesses on some big-endian systemsJonathan Nieder, Jul 14, 2012
  2. Linus TorvaldsJul 14, 2012
  3. Jonathan NiederJul 14, 2012
  4. Linus TorvaldsJul 14, 2012
  5. block-sha1: avoid pointer conversion that violates alignment constraintsJonathan Nieder, Jul 14, 2012
  6. Linus TorvaldsJul 14, 2012
  7. block-sha1: put macro arguments in parenthesesJonathan Nieder, Jul 14, 2012
  8. Michael CreeJul 15, 2012
  9. Jonathan NiederJul 15, 2012
  10. Michael CreeJul 16, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.