LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 1307 - SimplifyLibCalls miscompiles Python 2.5
Summary: SimplifyLibCalls miscompiles Python 2.5
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Interprocedural Optimizations (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2007-04-04 15:45 PDT by Anton Korobeynikov
Modified: 2010-02-22 12:56 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments
.ll File in question (160.28 KB, text/plain)
2007-04-04 15:46 PDT, Anton Korobeynikov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Korobeynikov 2007-04-04 15:45:18 PDT
Consider attached .ll file.

Running ./opt -simplify-libcalls will produce "bad" output. Resulting binary
just outputs "Bad HeadURL".

This breaks Python 2.5
Comment 1 Anton Korobeynikov 2007-04-04 15:46:34 PDT
Created attachment 758 [details]
.ll File in question
Comment 2 Chris Lattner 2007-04-06 16:58:22 PDT
This is a miscompilation of the strchr optimizer:
-       %tmp9 = call i8* @strchr( i8* getelementptr ([82 x i8]* @headurl, i32 0, i64 52), i32 47 )              ; 
<i8*> [#uses=3]
-       %tmp11 = getelementptr i8* %tmp9, i32 1         ; <i8*> [#uses=1]
+       %.strchr = getelementptr i8* getelementptr ([82 x i8]* @headurl, i32 0, i64 52), i64 18         ; 
<i8*> [#uses=3]
+       %tmp11 = getelementptr i8* %.strchr, i32 1              ; <i8*> [#uses=1]

it is turning (strchr(x+123, 47)) into strchr(x+4, 47)  instead of strchr(x+123+4, 47)

This looks like a design flaw in getConstantStringLength, I'm working on it.
Comment 3 Reid Spencer 2007-04-07 11:17:10 PDT
Is this done now?
Comment 4 Chris Lattner 2007-04-07 12:24:40 PDT
This specific one is, but there are other problems.
Comment 5 Chris Lattner 2007-04-08 02:01:32 PDT
This is now fixed, with many patches.