diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-03 07:41:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-03 07:41:54 +0000 |
commit | 053321731c501539ba48e158708568c3f8e17e46 (patch) | |
tree | db8ccb4cf350ca259f14f1bbfb69e61cffcafd19 /lib | |
parent | 93e0ed31c54cea6bf3f1f20244bd56a4770b2780 (diff) | |
download | external_llvm-053321731c501539ba48e158708568c3f8e17e46.zip external_llvm-053321731c501539ba48e158708568c3f8e17e46.tar.gz external_llvm-053321731c501539ba48e158708568c3f8e17e46.tar.bz2 |
add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/README.txt | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Target/README.txt b/lib/Target/README.txt index 2d8a687..2d513c8 100644 --- a/lib/Target/README.txt +++ b/lib/Target/README.txt @@ -1704,3 +1704,35 @@ need all but the bottom two bits from %A, and if we gave that mask to SDB it would delete the or instruction for us. //===---------------------------------------------------------------------===// + +FunctionAttrs is not marking this function as readnone (just readonly): +$ clang t.c -emit-llvm -S -o - -O0 | opt -mem2reg -S -functionattrs + +int t(int a, int b, int c) { + int *p; + if (a) + p = &a; + else + p = &c; + return *p; +} + +This is because we codegen this to: + +define i32 @t(i32 %a, i32 %b, i32 %c) nounwind readonly ssp { +entry: + %a.addr = alloca i32 ; <i32*> [#uses=3] + %c.addr = alloca i32 ; <i32*> [#uses=2] +... + +if.end: + %p.0 = phi i32* [ %a.addr, %if.then ], [ %c.addr, %if.else ] + %tmp2 = load i32* %p.0 ; <i32> [#uses=1] + ret i32 %tmp2 +} + +And functionattrs doesn't realize that the p.0 load points to function local +memory. + +//===---------------------------------------------------------------------===// + |