[LLVMdev] Should this function be omitted?

Fernando Pelliccioni fpelliccioni at gmail.com
Sun May 4 16:17:03 PDT 2014


Hi all,

Is there any reason why the following code produces the attached assembly
code?

    struct X { int v; };

    int func( X** x, int n )
    {
        int sum = 0;

        while ( n > 0 )
        {
            sum += (*x)->v;
            ++x;
            --n;
        }
        return sum;
    }

    int main() {}

The "func" function is not used, I think it should be omitted by the
linked. Should it?

Compiled using:
    clang++ -S -O3 -std=c++11 -S code.cpp

clang++ --version
    clang version 3.5 (trunk 200620)
    Target: x86_64-apple-darwin13.1.0
    Thread model: posix

Assembly code generated:
    http://pastebin.com/aY8rAXyQ

Best,
Fernando.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140504/7eb13dd7/attachment.html>


More information about the llvm-dev mailing list