[llvm-dev] Strange opt result

Eli Friedman via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 24 11:33:20 PDT 2016


On Fri, Jun 24, 2016 at 8:32 AM, Martin Schreiber via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi,
> opt -O1 converts the attached test.ll to test_opt.ll.
> "
> opt --version
> LLVM (http://llvm.org/):
>   LLVM version 3.8.0
>   DEBUG build with assertions.
>   Built Jun 23 2016 (18:32:09).
>   Default target: i686-pc-linux-gnu
>   Host CPU: k8-sse3
> "
>
> test.ll:
> "
> ; ModuleID = 'test.bc'
>

You need to set a "target datalayout" and "target triple" before you run a
program through the optimizer.  For example, for 32-bit Linux, clang
generates:

target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i386-unknown-linux-gnu"

If you don't do this, the optimizer will make bad assumptions; among other
things, it will assume pointers are 64-bit.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160624/6f923f4c/attachment.html>


More information about the llvm-dev mailing list