http://llvm.org/bugs/show_bug.cgi?id=6394
Henning Thielemann <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WORKSFORME | --- Comment #10 from Henning Thielemann <[email protected]> 2011-01-17 16:12:03 CST --- I have snooped the calls to LLVM of my Haskell program using ltrace and turned the output into a stand-alone C program. Attached is this program that should work like 'opt -O1'. It reads a Bitcode file from stdin, sets target data and writes back to stdout. If I do not set target data, the optimized code is correct. I have not written the Haskell code that calls the LLVMAddTargetData function, but I could remove it, if this is wrong. Nevertheless I wonder, why setting the target data this way makes the optimizer go wrong and I wonder, why I can set arbitrary strings like "foobar" that yield the same optimizer misbehaviour. I think either LLVMCreateTargetData or LLVMAddTargetData should at least have an assert for nonsense strings. Here is how I get the results: $ cat opt64.ll %wrap = type { float, <4 x float>* } define void @_myfree(float*) { _L1: %1 = bitcast float* %0 to %wrap* %2 = getelementptr %wrap* %1, i32 0, i32 1 %3 = load <4 x float>** %2 free <4 x float>* %3 ret void } $ llvm-as -f opt64.ll $ gcc -lLLVM-2.8rc `llvm-config --cflags` -o opt64simplec opt64simplec.c $ opt64simplec <opt64.bc >opt64-opt.bc $ llvm-dis -o opt64-opt-dis.ll -f opt64-opt.bc $ cat pt64-opt-dis.ll ; ModuleID = 'opt64-opt.bc' define void @_myfree(float* nocapture) nounwind { _L1: %1 = getelementptr float* %0, i64 2 %2 = bitcast float* %1 to <4 x float>** %3 = load <4 x float>** %2, align 8 %4 = bitcast <4 x float>* %3 to i8* tail call void @free(i8* %4) ret void } declare void @free(i8* nocapture) nounwind -- 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. _______________________________________________ LLVMbugs mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs
