Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
what is best in optimizer pipeline
value numbering
code motion
peepholing
loop idiom recognition
legalization
thread gassing
op banning
View Results
 
  • Locked thread
Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

rjmccall posted:

apple's arm32 abi is pretty terrible, mostly around floating-point arguments. the calling convention clearly predates the idea that arm processors might drive general-purpose computation and/or actually have a floating-point unit; it's basically an all-arguments-on-stack convention that pops the first 16 bytes into integer registers, which means e.g. an early double will get passed as two ints. also the arm bitfield layout rules are needlessly different from the standard sysv rules

actually that's something that i've wondered about. was there any particular reason apple had to use the lovely arm abi rather than diverging like with arm64, or is that just one of those ideas that just never came up until years after it was too late to be practical?

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
that predates me, but the story i've heard is that it was just expedient: it was the only abi implemented in the version of gcc we were using for bringup. there was plenty of other compiler work to do at the time, and it was okay to put off because we didn't have binary compatibility requirements until we added the app store. we did actually change a bunch of stuff before releasing the first ios sdk, including some fundamental abi stuff; for example, earlier versions of ios actually used the fragile objc runtime and setjmp/longjmp exceptions. but there was too much other stuff in flight, and too much assembly already written, for anybody to go back and change the basic calling convention

the apple arm64 abi is actually very close to arm's. the major difference is the variadic calling convention. my understanding is that arm was considering using our rule but ultimately backed off because they got tired of chasing down the bugs it was exposing. i remember a lot of grumbling within apple, too, but it's just such a superior way of doing varargs that we decided to persevere

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

rjmccall posted:

earlier versions of ios actually used the fragile objc runtime

you mean as opposed to the Foundation framework? btw why don't you publish the source code, I'm tired of using gnustep as a reference

Workaday Wizard
Oct 23, 2009

by Pragmatica

rjmccall posted:

the apple arm64 abi is actually very close to arm's. the major difference is the variadic calling convention. my understanding is that arm was considering using our rule but ultimately backed off because they got tired of chasing down the bugs it was exposing. i remember a lot of grumbling within apple, too, but it's just such a superior way of doing varargs that we decided to persevere

how complex can a variadic calling convention be? and why would it be exposing bugs?

TOPS-420
Feb 13, 2012

there’s a lot of old bad c code that assumes it’s still 1979 and arguments are always passed on the stack, so assumes void (*)(butts, ...) can be cast to void (*)(butts, farts) or K&R-style void (*)() and still be called. the c standard says calling a variadic function as not variadic or vice versa is undefined behavior, but most ABIs oblige and implement varargs in a way that works with the normal convention. a lot of bad code also assumes va_list is a flat array of bytes. this is why a lot of older risc-ish abis, rjmccall mentioned 32 bit ARM but also alpha, ppc, and even win64, pass arguments in registers but also reserve shadow space on the stack. that way va_start can spill all the argument registers into their shadow slots, and then va_list can “just” be a flat array. this of course wastes a ton of stack space

with x86-64 amd finally said “use va_arg you idiots” and standardized the abi to only pass args in registers without reserving shadow stack space. however they still maintained compatibility between variadic and normal calling conventions, so the va_list implementation is a nightmare. read https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf#page55 to be terrified

apple arm64 finally did the reasonable thing and said, hey, you can’t do this, it’s UB so the compiler will gently caress you over even if the runtime abi seems to work. so normal arguments get passed in registers and varargs get passed on the stack

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
that's a great explanation and i have nothing to add to it

Luigi Thirty
Apr 30, 2006

Emergency confection port.

I left GCC 5.2 compiling on my G3 iMac all night and when I checked it in the morning it had failed with a CPU subtype not supported error

thanks homebrew

thomebrew

The Management
Jan 2, 2010

sup, bitch?
hey, how about we make a c compiler that doesn't need declarations of local functions before use because it's not the 70's anymore?

no, I don't care about the standard.

Sagebrush
Feb 26, 2012

i think that would be pretty cool and good, especially seeing as arduino-C has done that for a decade with no issues

The Management
Jan 2, 2010

sup, bitch?

rjmccall posted:

apple's arm32 abi is pretty terrible, mostly around floating-point arguments. the calling convention clearly predates the idea that arm processors might drive general-purpose computation and/or actually have a floating-point unit; it's basically an all-arguments-on-stack convention that pops the first 16 bytes into integer registers, which means e.g. an early double will get passed as two ints. also the arm bitfield layout rules are needlessly different from the standard sysv rules

AEABI was out before we shipped the Aspen OS 2 (with the App Store) and it fixes most of the stupid things in the old ABI, including passing floating point arguments in FPU registers. iPod engineering switched to it because they were using ARM's compiler. iPhoneOS didn't because they were stuck with lovely gcc.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
yeah, eabi is a lot better, as is the abi we use for the watch

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

The Management posted:

hey, how about we make a c compiler that doesn't need declarations of local functions before use because it's not the 70's anymore?

no, I don't care about the standard.

use c++ and make all of your functions templates

The Management
Jan 2, 2010

sup, bitch?

you go to hell

theodop
Dec 30, 2005

rock solid, heart touching
you guys are really smart

RISCy Business
Jun 17, 2015

bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork bork
Fun Shoe

theodop posted:

you guys are really smart

:wrong:

Notorious b.s.d.
Jan 25, 2003

by Reene

rjmccall posted:

yeah, eabi is a lot better, as is the abi we use for the watch

the watch has its own abi ?

(as a related matter: does the touchbar run the same OS as the watch?)

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
watchOS and tvOS are really wacky and different in ways that you would probably not expect

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
i guess "wacky" has overly negative connotations, but they definitely took advantage of the chance to make backwards-incompatible changes

The Management
Jan 2, 2010

sup, bitch?

Notorious b.s.d. posted:

the watch has its own abi ?

(as a related matter: does the touchbar run the same OS as the watch?)

what do you mean when you say "the same OS"?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
tvOS uses the normal arm64 abi iirc, there are just some framework level changes

watchOS is very different at the abi level because as mentioned the 32-bit iOS abi really sucks

Notorious b.s.d.
Jan 25, 2003

by Reene

The Management posted:

what do you mean when you say "the same OS"?

well it didn't dawn on me until you guys brought it up that they would be anything but ios

since you are using a non-ios 32 bit abi, does that mean the whole system is 32 bit? is there a 32 bit kernel shared between watchos and ... whatever runs on the touchbar embedded thing?

The Management
Jan 2, 2010

sup, bitch?

Notorious b.s.d. posted:

well it didn't dawn on me until you guys brought it up that they would be anything but ios

since you are using a non-ios 32 bit abi, does that mean the whole system is 32 bit? is there a 32 bit kernel shared between watchos and ... whatever runs on the touchbar embedded thing?

the definition of what is "iOS" is not exactly clean cut.

it runs a Darwin OS (kernel plus system libraries), which is the same on everything from watch to phone to Mac. it has some kind of UI framework that is probably based on UIKit but who knows how they cut it down. since it doesn't run third party apps I don't see why it matters what the ABI is, they chose the best one for the architecture.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
the kernel isn't the same everywhere. it's a single code base, but there's nontrivial differences in what's enabled for each platform

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
it's not literally the same build, no, but we manage to say that various linux distributions are built on the same kernel despite each configuring it differently

JawnV6
Jul 4, 2004

So hot ...
i got tricked by a compiler

i left a status thing uninitialized, it determined that the only value assigned was ERROR, elided the entire function and just kicked that back

that all makes sense, but why wouldn't volatile writes prevent the total collapse? shouldn't those get preserved even if the rest of the code drops away?

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JawnV6 posted:

i got tricked by a compiler

i left a status thing uninitialized, it determined that the only value assigned was ERROR, elided the entire function and just kicked that back

that all makes sense, but why wouldn't volatile writes prevent the total collapse? shouldn't those get preserved even if the rest of the code drops away?

it probably decided that something you were doing was undefined behavior and therefore that such-and-such path could never be taken

JewKiller 3000
Nov 28, 2006

by Lowtax
that'll teach you to program in C :colbert:

JawnV6
Jul 4, 2004

So hot ...

rjmccall posted:

something you were doing was undefined behavior
:mad:

The Management
Jan 2, 2010

sup, bitch?

I.e., you were writing a non trivial program

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

:nono:

big shtick energy
May 27, 2004


the volatile write was to a global variable, right, and not to something local like a pointer you declared locally within the function?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

The Management posted:

I.e., you were writing a program

TOPS-420
Feb 13, 2012

avoiding ub is easy, just follow these 204 simple rules

https://blog.regehr.org/archives/1520

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



i wanna compile a butt irl, but how?

A Pinball Wizard
Mar 23, 2005

I know every trick, no freak's gonna beat my hands

College Slice

Powaqoatse posted:

i wanna compile a butt irl, but how?

txt me

Dylan16807
May 12, 2010

TOPS-420 posted:

avoiding ub is easy, just follow these 204 simple rules

https://blog.regehr.org/archives/1520

is there a reason they don't get rid of all the ub for trivial things like syntax errors? how did "An unmatched ‘ or ” character is encountered on a logical source line during tokenization (6.4)" survive into this century?

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang




no u :wink:

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Dylan16807 posted:

is there a reason they don't get rid of all the ub for trivial things like syntax errors? how did "An unmatched ‘ or ” character is encountered on a logical source line during tokenization (6.4)" survive into this century?

practically speaking, they haven't; there are no significant compilers that will fail to diagnose that

Mikey-San
Nov 3, 2005

I'm Edith Head!

Powaqoatse posted:

i wanna compile a butt irl, but how?

first you need a butt compiler compiler

Adbot
ADBOT LOVES YOU

Doom Mathematic
Sep 2, 2008

Dylan16807 posted:

is there a reason they don't get rid of all the ub for trivial things like syntax errors? how did "An unmatched ‘ or ” character is encountered on a logical source line during tokenization (6.4)" survive into this century?

Why can there be undefined behaviour at parsing time?

  • Locked thread