diff mbox series

[v2,1/2] ARM: drop WASM to work around LLVM issue

Message ID e3f3bf27430712ee88c0b600f3d62cb86d327b75.1552863571.git.stefan@agner.ch (mailing list archive)
State Mainlined, archived
Commit 43947b8890b4734e34e889a2df52734e0081a097
Headers show
Series [v2,1/2] ARM: drop WASM to work around LLVM issue | expand

Commit Message

Stefan Agner March 17, 2019, 11:05 p.m. UTC
Currently LLVM's integrated assembler does not recognize .w form
of the pld instructions (LLVM Bug 40972 [0]):

  ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
                          "pldw.w\t%a0 \n"
                           ^
  <inline asm>:2:1: note: instantiated into assembly here
  pldw.w  [r0]
  ^
  1 error generated.

The W macro for generating wide instructions when targeting Thumb-2
is not strictly required for the preload data instructions (pld, pldw)
since they are only available as wide instructions. The GNU assembler
works with or without the .w appended when compiling an Thumb-2 kernel.

Drop the macro to work around LLVM Bug 40972 issue.

[0] https://bugs.llvm.org/show_bug.cgi?id=40972

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
Changes in v2:
- Reword commit message to reflect the fact that this is a work around
  for LLVM.

 arch/arm/include/asm/processor.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nick Desaulniers March 18, 2019, 6:09 p.m. UTC | #1
On Sun, Mar 17, 2019 at 4:05 PM Stefan Agner <stefan@agner.ch> wrote:
>
> Currently LLVM's integrated assembler does not recognize .w form
> of the pld instructions (LLVM Bug 40972 [0]):
>
>   ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
>                           "pldw.w\t%a0 \n"
>                            ^
>   <inline asm>:2:1: note: instantiated into assembly here
>   pldw.w  [r0]
>   ^
>   1 error generated.
>
> The W macro for generating wide instructions when targeting Thumb-2
> is not strictly required for the preload data instructions (pld, pldw)
> since they are only available as wide instructions. The GNU assembler
> works with or without the .w appended when compiling an Thumb-2 kernel.
>
> Drop the macro to work around LLVM Bug 40972 issue.
>
> [0] https://bugs.llvm.org/show_bug.cgi?id=40972
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

Thanks for the bug report and patch.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

Just curious, there are only 3 other expansion sites of this macro.
Are any of those problematic?  Looks like nop.w, sev.w and b.w?

> ---
> Changes in v2:
> - Reword commit message to reflect the fact that this is a work around
>   for LLVM.
>
>  arch/arm/include/asm/processor.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
> index 57fe73ea0f72..5d06f75ffad4 100644
> --- a/arch/arm/include/asm/processor.h
> +++ b/arch/arm/include/asm/processor.h
> @@ -135,8 +135,8 @@ static inline void prefetchw(const void *ptr)
>         __asm__ __volatile__(
>                 ".arch_extension        mp\n"
>                 __ALT_SMP_ASM(
> -                       WASM(pldw)              "\t%a0",
> -                       WASM(pld)               "\t%a0"
> +                       "pldw\t%a0",
> +                       "pld\t%a0"
>                 )
>                 :: "p" (ptr));
>  }
> --
> 2.21.0
>
Stefan Agner March 19, 2019, 10:07 p.m. UTC | #2
On 18.03.2019 19:09, Nick Desaulniers wrote:
> On Sun, Mar 17, 2019 at 4:05 PM Stefan Agner <stefan@agner.ch> wrote:
>>
>> Currently LLVM's integrated assembler does not recognize .w form
>> of the pld instructions (LLVM Bug 40972 [0]):
>>
>>   ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
>>                           "pldw.w\t%a0 \n"
>>                            ^
>>   <inline asm>:2:1: note: instantiated into assembly here
>>   pldw.w  [r0]
>>   ^
>>   1 error generated.
>>
>> The W macro for generating wide instructions when targeting Thumb-2
>> is not strictly required for the preload data instructions (pld, pldw)
>> since they are only available as wide instructions. The GNU assembler
>> works with or without the .w appended when compiling an Thumb-2 kernel.
>>
>> Drop the macro to work around LLVM Bug 40972 issue.
>>
>> [0] https://bugs.llvm.org/show_bug.cgi?id=40972
>>
>> Signed-off-by: Stefan Agner <stefan@agner.ch>
> 
> Thanks for the bug report and patch.
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> 
> Just curious, there are only 3 other expansion sites of this macro.
> Are any of those problematic?  Looks like nop.w, sev.w and b.w?
> 

All three sites are in inline assembly, and I did a bunch of successful
Thumb2 builds using the integrated assembler, so I think all those sites
have been assembled by LLVM successfully.

Also confirmed those three instructions with the reproducer example from
the LLVM bug above.

--
Stefan

>> ---
>> Changes in v2:
>> - Reword commit message to reflect the fact that this is a work around
>>   for LLVM.
>>
>>  arch/arm/include/asm/processor.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
>> index 57fe73ea0f72..5d06f75ffad4 100644
>> --- a/arch/arm/include/asm/processor.h
>> +++ b/arch/arm/include/asm/processor.h
>> @@ -135,8 +135,8 @@ static inline void prefetchw(const void *ptr)
>>         __asm__ __volatile__(
>>                 ".arch_extension        mp\n"
>>                 __ALT_SMP_ASM(
>> -                       WASM(pldw)              "\t%a0",
>> -                       WASM(pld)               "\t%a0"
>> +                       "pldw\t%a0",
>> +                       "pld\t%a0"
>>                 )
>>                 :: "p" (ptr));
>>  }
>> --
>> 2.21.0
>>
diff mbox series

Patch

diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 57fe73ea0f72..5d06f75ffad4 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -135,8 +135,8 @@  static inline void prefetchw(const void *ptr)
 	__asm__ __volatile__(
 		".arch_extension	mp\n"
 		__ALT_SMP_ASM(
-			WASM(pldw)		"\t%a0",
-			WASM(pld)		"\t%a0"
+			"pldw\t%a0",
+			"pld\t%a0"
 		)
 		:: "p" (ptr));
 }