Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Created February 10, 2016 08:47
Show Gist options
  • Save alexcrichton/ed55017740d6320044ff to your computer and use it in GitHub Desktop.
Save alexcrichton/ed55017740d6320044ff to your computer and use it in GitHub Desktop.
set -ex
export PATH=$PATH:`pwd`/i686-unknown-linux-gnu/llvm/Release/bin
export MALLOC_CHECK_=7
./i686-unknown-linux-gnu/stage0/bin/rustc foo.rs -Clto -O --emit link,llvm-ir
(./foo && exit 1 || exit 0)
cat foo.ll | \
sed 's/define i32/define internal i32/' | \
sed 's/define void/define internal void/' | \
sed 's/define zeroext/define internal zeroext/' | \
sed 's/define i8/define internal i8/' | \
sed 's/noinline//' | \
grep -v llvm.lifetime | \
sed 's/define internal i32 @main/define i32 @main/' | \
sed 's/= constant/= internal constant/' | \
sed '/define.*oom3oom/a\
another-entry: \
unreachable' | \
sed 's/= global/= internal global/' \
> foo-tmp.ll
opt -O2 -S foo-tmp.ll | tee foo-opt.ll | llc -filetype=obj -o foo-tmp.o
gcc foo-tmp.o -o foo-tmp -m32 -lm
(./foo-tmp && exit 1 || exit 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment