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
Raluek
Nov 3, 2006

WUT.

hifi posted:

go just has a requirement of go 1.4 which was the last one you could traditionally compile.

i remember reading an article about what would we do if all the hard drives everywhere were wiped but i can't find it

restore from tape, probably

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Gazpacho posted:

yosproject: successfully toggle a program that beeps into an x86 using a manually switched JTAG fixture
you're controlling the clock, so the mechanical part isn't all that taxing just tedious, hundreds but not thousands

you'd catch the reset, then key in a write of like 6 bytes to the reset vector which would land in the cache, release reset and go

2 bytes to port, 2 bytes to mangle the arg, 2 bytes to jump back to 0xfffffff0

hifi posted:

i remember reading an article about what would we do if all the hard drives everywhere were wiped but i can't find it
some goon, swsp?, did a paper or something about that

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
it's fun to imagine starting from scratch: writing a primitive assembler in machine code, then a primitive compiler in assembly, then slowly bootstrapping that into a complete system

on the other hand, how exactly are we writing the machine code without a computer? once upon a time i think you could toggle this stuff directly into memory using switches or something on the side of the storage system, but those days are gone. and why did They Who Done The Event wipe all the drives but not any of the firmware? maybe somebody hid a compiler in the firmware. oh, and a kernel, that would be grand

emoji
Jun 4, 2004
tfw your mom programmed punch cards back in the day but can't set up a router (until you forced her to go mac)

hifi
Jul 25, 2012

i think the idea was find the best microprocessor that could run at 0hz and do whatever the plan was with switches

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

JewKiller 3000 posted:

alright those were all easy let's do a fun one. what optimization passes do you think are most dangerous? i'm not referring to how they interact with a buggy program, because that would vary based on the program, i mean the compiler code itself. which aggressive optimizations are most likely to accidentally generate incorrect code because they're hella complicated/old/unmaintained/no one sane ever uses them? and don't tell me none or i'll ask for a formal proof :v:

that would vary with the compiler a lot

in clang, i can tell you that the objc arc optimizer is a bit suspect. it used to be really buggy, and then we neutered it a lot, and now i think it mostly just doesn't optimize all that well

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

emoji posted:

tfw your mom programmed punch cards back in the day but can't set up a router (until you forced her to go mac)

apparently my mom did this one summer. she doesn't remember much about it though

gonadic io
Feb 16, 2011

>>=
im -std=c99 -wall -werror -wreallyall

echinopsis
Apr 13, 2004

by Fluffdaddy
how does a compiler even work

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

The Management posted:

if by first class you mean broken every other day then m4 is fully supported.

what's the alternative to compiling cross compilers? you just want to download a binary that builds for EVERYTHING?

yeah, exactly, or at least some of the more popular targets: native and arm. clang can do it pretty well like rjmccall set because clang is already separate from llvm: the different thing you need is the llvm side that emits arm code instead of x86 or whatever.

the thing that honestly makes this an unrealistic whine instead of a real complaint is that arm-gcc-embedded is actually maintained by arm employees; but still, i (and i think a lot of other people, there are of course some politics in an email thread i can't be bothered to search for) really wish gcc had as clean a separation of frontend and back end as clang/llvm so you wouldn't have to recompile the goddamn binary every goddamn time.

feedmegin
Jul 30, 2008

rjmccall posted:

it's fun to imagine starting from scratch: writing a primitive assembler in machine code, then a primitive compiler in assembly, then slowly bootstrapping that into a complete system

on the other hand, how exactly are we writing the machine code without a computer? once upon a time i think you could toggle this stuff directly into memory using switches or something on the side of the storage system, but those days are gone. and why did They Who Done The Event wipe all the drives but not any of the firmware? maybe somebody hid a compiler in the firmware. oh, and a kernel, that would be grand

What if the firmware is OpenFirmware and you already have a nice Forth to play with?

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮

rjmccall posted:

on the other hand, how exactly are we writing the machine code without a computer? once upon a time i think you could toggle this stuff directly into memory using switches or something on the side of the storage system, but those days are gone.

are they?

https://www.youtube.com/watch?v=EV1ki6LiEmg

gonadic io
Feb 16, 2011

>>=

echinopsis posted:

how does a compiler even work

a miserable pile of buffer overflows

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

awesome

Silver Alicorn
Mar 30, 2008

𝓪 𝓻𝓮𝓭 𝓹𝓪𝓷𝓭𝓪 𝓲𝓼 𝓪 𝓬𝓾𝓻𝓲𝓸𝓾𝓼 𝓼𝓸𝓻𝓽 𝓸𝓯 𝓬𝓻𝓮𝓪𝓽𝓾𝓻𝓮
yours for only $621

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

i love the way that this triggers certain people

"the C code I wrote in 1992 ran as I expected then and is therefore correct and should always run as it did!"

I'll admit to a slight amount of this myself: I do expect things like *foo = 12; to work even if foo is NULL because IMO dereferncing NULL shouldn't be undefined in C as it can be important in certain use cases (embedded & OS work on some architectures), but I'm OK with that being an extension that has to be enabled

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Raluek posted:

restore from tape, probably

tfw u boot from tape

(actually booted and installed an Apollo from "tape" in MAME, 'twas interesting though not as interesting as actually using the system)

(also never actually used the QIC drive on my LispM)

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

rjmccall posted:

the way better alternative is to say that basic blocks can have parameters and gotos can have arguments, which ends up looking kindof like a functional program with a lot of explicit tail calls:

code:

  if %whatever goto trueBlock else goto falseBlock
trueBlock:
  %fooResult = call @foo()
  goto contBlock(%fooResult)
falseBlock:
  %barResult = call @bar()
  goto contBlock(%barResult)
contBlock(%mergedValue):
  call @baz(%mergedValue)

this looks like a transformation, is there a semantic difference I'm not seeing or is it really just a means of making phi nodes implicit so they're easier to reason about?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Cocoa Crispies posted:

write one to disabuse yourself of that notion

start by reading An Incremental Approach to Compiler Construction and the more complete tutorial Compilers: Backend to Frontend and Back to Front Again

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

thanks for these

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

or just crack open a cold one and spend a few minutes compiling a lovely postscript/forth style calculator to c

gonadic io
Feb 16, 2011

>>=
RPN calculator, bonus points if you make the target language register-based

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

eschaton posted:

i love the way that this triggers certain people

you know what else it triggers? exploitable holes in kernels!

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

eschaton posted:

this looks like a transformation, is there a semantic difference I'm not seeing or is it really just a means of making phi nodes implicit so they're easier to reason about?

phi-like branch arguments can be restricted to specific terminators, other terminators can introduce path-specific values in a natural way. it's not like inherently more expressive, no

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde
its a shame these scheme-heads haven't written compiler intros about a language that someone would actually use

Workaday Wizard
Oct 23, 2009

by Pragmatica
how does incremental compilation work? what are the different approaches? are there any really good examples out there?

in my mind it's just having a dictionary of AST nodes and binary code but i don't really know.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
it really depends on how far away from the normal compiler output you want to get. in general it's stupider than you think though

swift's incremental compilation is currently just compiler-directed dependency tracking and we still type-check and re-emit the entire object file from scratch. that's way less incremental than it ought to be, but it has the distinct advantage of making it easy to validate that incremental builds are producing the same results as non-incremental builds

on the other end of the spectrum there are systems where the incremental result is a sort of patch file to the previous executable. so the results of incremental builds are really different from the results of from-scratch builds, but only the precise minimum needs to change

Plorkyeran
Mar 22, 2007

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

rjmccall posted:

in clang, i can tell you that the objc arc optimizer is a bit suspect. it used to be really buggy, and then we neutered it a lot, and now i think it mostly just doesn't optimize all that well

these days it seems to do an okay job with purely local analysis but never ever optimizes away retain/release pairs for function arguments even if the function gets inlined, which i guess is in practice probably not an issue for idiomatic obj-c that doesn't have anything that can be inlined

Dylan16807
May 12, 2010

redleader posted:

oh yeah, that's right

related (but possibly a little off topic) question: what's up with the c/c++ standards committees that makes them prefer undefined over implementation-defined behavior? i mean surely most compilers would know their target's behavior with (un)signed overflow (for example)

let's take something like arithmetic. sometimes it's faster to let it overflow. sometimes it's faster to treat it as ideal numbers and assume x+1>x. leaving it undefined lets the compiler pick the best option in each individual case, in a way that implementation-defined couldn't effectively detail.

and while it would be nice to have a rule that a series of arithmetic statements will eventually resolve to some number instead of formatting your hard drive, it's really hard to write a set of rules that preserve both safety and optimizations

crazypenguin
Mar 9, 2005
nothing witty here, move along
anyone read that "compiling without continuations" paper

I could use some intuition help.

Their jfloat rules duplicate the context E both within the join point and in the remainder of the expression. I don't (think?) it ever spells out why

Is this because (a) we want to push that info down as aggressively as possible (b) we CAN do this because "jumps" are always (ostensibly) tail-calls and (c) the "abort" rule cleans up the extra nonsensical junk that gets jammed onto our jumps? (And this is the reason for the funky type rules on jumps/join points? Essentially this transformation is changing the type of the join point, and we're accounting for that in a separate step using the abort rule?)

I just noticed the operational semantics for "jump" also discards part of the stack (the s' bit...) which corresponds to the abort rule removing that junk.

...okay after actually writing out my question I think that I'm right, but I'm just going to post anyway.

Angela Merkle Tree
Jan 4, 2012

the definition of open: "mkdir android ; cd android ; repo init -u git://android.git.kernel.org/platform/manifest.git ; repo sync ; make"
College Slice

Shinku ABOOKEN posted:

how does incremental compilation work? what are the different approaches? are there any really good examples out there?

in my mind it's just having a dictionary of AST nodes and binary code but i don't really know.

i have no formal compiler experience but hacked together a compiler and code reloader for gta:sa's script engine, and the way i implemented it was storing the symbol list from the previous compile, and patching jumps that reference the changed code in the process's memory

you could potentially do the same thing for binaries on-disk, but you might need a fancy executable container that allows you to shove new code in at the end? i don't actually know much about this stuff lol

JawnV6
Jul 4, 2004

So hot ...
whats the worst ABI you've actually had to emit against

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
is it PowerPC Mach-O, which is gratuitously different than the ABI defined as part of the architecture itself?

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
is it the classic Mac, where calls to OS & Toolbox functions had to be emit as individual instructions in the 0xA000 range, some passing parameters and receiving return values via specific registers, and where every 32KB of code had to be in its own segment due to the use of PC-relative addressing for everything (to accommodate manual loading and unloading of segments on low-memory systems)?

echinopsis
Apr 13, 2004

by Fluffdaddy
does writing a compiler (presumably understanding it while doing so rather than apeing something else) make you a better coder

TOPS-420
Feb 13, 2012

oh hey yospos whats goin on in this thread

eschaton posted:

is it PowerPC Mach-O, which is gratuitously different than the ABI defined as part of the architecture itself?

you forgot to link the classic bit of nerd rage on this topic

http://archive.li/rDmyF

some vintage cisc vs risc war bullshit there. really it should be "good isas with pc-relative addressing" vs "powerpc (a bad isa)". on a platform where 90% of calls are objc_msgSend or otherwise dynamically dispatched, keeping a toc pointer probably would have been a net loss in performance too vs using plain function pointers and eating the PIC cost for cross-library calls

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
yeah the best part of that article is the repeated conflation of the problem with like a million other things. notably it is not characteristic of cisc architectures to give you direct access to the pc. anyway yeah i get what they were trying to do with the ppc abi but ugh, doing pic on pre-pic architectures is just the worst

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

i386 is just really old and passes all arguments on the stack, which you'd think would be simple but it actually causes a lot of complexity because there are a dozen different non-standard calling conventions and abi flags that people use to try to speed things up. also there are a ton of special cases with return values, like how complex floats get returned as two values on the floating point stack but a struct of two floats gets returned in memory

Star War Sex Parrot
Oct 2, 2003

rjmccall posted:

i386 is just really old and passes all arguments on the stack
You're talking specifically IA32, yeah? x86-64 changed that, I thought. First 6 arguments are in registers and 7+ on the stack

TOPS-420
Feb 13, 2012


this seems like a p cool approach to get some of the benefits of both

http://compilers.cs.uni-saarland.de/papers/lkh15_cgo.pdf

it's cps but with the structure implied by the dataflow graph instead of scoping, so you can lower all your idiot higher order functions, coroutines, and tail recursion without concretizing a bunch of intermediate closure structures that will just get picked apart by obvious optimizations

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

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

echinopsis posted:

does writing a compiler (presumably understanding it while doing so rather than apeing something else) make you a better coder

writing anything that is significantly different from things you have worked on before while putting in the effort to properly understand why you're doing what you're doing will make you a better coder

  • Locked thread