[LLVMbugs] [Bug 3754] New: FunctionAttrs pass marks function with MallocInst as readnone
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Sat Mar 7 18:18:43 PST 2009
http://llvm.org/bugs/show_bug.cgi?id=3754
Summary: FunctionAttrs pass marks function with MallocInst as
readnone
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Interprocedural Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: nicholas at mxc.ca
CC: llvmbugs at cs.uiuc.edu
$ cat m3.ll
define i32 @foo_malloc(i32 %n) nounwind noinline {
entry:
%0 = icmp eq i32 %n, 0 ; <i1> [#uses=1]
%iftmp.0.0 = select i1 %0, i32 1, i32 %n ; <i32>
[#uses=1]
%1 = malloc i8, i32 %iftmp.0.0 ; <i8*> [#uses=1]
%2 = ptrtoint i8* %1 to i32 ; <i32> [#uses=1]
ret i32 %2
}
$ llvm-as < m3.ll | opt -functionattrs -stats -disable-output
===-------------------------------------------------------------------------===
... Statistics Collected ...
===-------------------------------------------------------------------------===
1 functionattrs - Number of functions marked readnone
That's wrong as can be seen from this C program:
#include <stdlib.h>
int foo_malloc(unsigned n) __attribute__((noinline));
int foo_malloc(unsigned n) {
return malloc(n ? n : 1);
}
int main(void) {
void *x, *y;
x = foo_malloc(10);
y = foo_malloc(10);
return x == y;
}
The malloc instruction does write to memory, but it's sorta a secret special
"new memory" pointer that no other pointer in LLVM can see. :) I'm filing this
bug instead of just fixing it because I'm not sure what the fix out to be.
Make FunctionAttrs treat MallocInst specially? Set
MallocInst->mayWriteToMemory() to true?
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list