[cfe-dev] Clang x86-64 can't move segment registers

Tobias Hahn via cfe-dev cfe-dev at lists.llvm.org
Tue Jun 5 10:56:02 PDT 2018


Oh indeed, it does `:)

T

> Am 05.06.2018 um 19:39 schrieb Craig Topper <craig.topper at gmail.com>:
> 
> I think if you press the binary button on the godbolt output it will fail on gcc. I don’t think it feeds it to the assembler without that.
> 
> On Tue, Jun 5, 2018 at 10:28 AM Tobias Hahn <tobias.hahn at ableton.com> wrote:
> Thanks, that fixes it. I'll file it against PLCrashReporter. FWIW, gcc trunk still seems to accept it: https://godbolt.org/g/un7WJM
> 
> Thanks again!
> Tobias
> 
> > Am 05.06.2018 um 17:59 schrieb Craig Topper <craig.topper at gmail.com>:
> > 
> > It should be movw. The segment registers are only 16-bits wide. We used to accept it because the Intel documentation sort of makes it look valid because you can use a 64-bit GPR as the destination, but it doesn't make any sense to use 64-bits when writing to memory. GNU assembler 2.30 feels the same way so it probably doesn't work in gcc either.
> > 
> > ~Craig
> > 
> > 
> > On Tue, Jun 5, 2018 at 8:39 AM Tobias Hahn via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> > Since clang 6, the following code produces `error: invalid operand for instruction`:
> > 
> > ```c++
> > void f()
> > {
> >   asm("movq %cs, 160(%rsp);");
> >   asm("movq %fs, 168(%rsp);");
> >   asm("movq %gs, 176(%rsp);");
> > }
> > ```
> > (see https://godbolt.org/g/CgPBb9)
> > 
> > Two questions: 1. Is this a bug or a feature? 2. Is this a clang bug/feature or an llvm one (a.k.a what is the right place to report this)?
> > 
> > (Background: I ran into this while trying to roll clang to a new version in a project containing PLCrashReporter, which uses these instructions while capturing a thread context, see [1]. I'm now trying to figure out if this is a compiler bug or if PLCrashReporter needs to be patched.)
> > 
> > Thanks!
> > Tobias
> > 
> > [1] https://github.com/plausiblelabs/plcrashreporter/blob/master/Source/PLCrashAsyncThread_current.S#L96
> > 
> > Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany
> > Sitz (Registered Office) Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838
> > Vorstand (Management Board): Gerhard Behles, Jan Bohl
> > Vorsitzender des Aufsichtsrats (Chair of the Supervisory Board): Uwe Struck
> > 
> > 
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> 
> Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany
> Sitz (Registered Office) Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838
> Vorstand (Management Board): Gerhard Behles, Jan Bohl
> Vorsitzender des Aufsichtsrats (Chair of the Supervisory Board): Uwe Struck
> 
> 
> -- 
> ~Craig

Ableton AG, Schoenhauser Allee 6-7, 10119 Berlin, Germany
Sitz (Registered Office) Berlin, Amtsgericht Berlin-Charlottenburg, HRB 72838
Vorstand (Management Board): Gerhard Behles, Jan Bohl
Vorsitzender des Aufsichtsrats (Chair of the Supervisory Board): Uwe Struck





More information about the cfe-dev mailing list