[llvm-dev] how LLVM deals with 'undef'
Jeremy Lakeman via llvm-dev
llvm-dev at lists.llvm.org
Tue Aug 25 22:01:42 PDT 2015
Just because you don't see an 'undef' doesn't mean there isn't any
undefined behaviour already present in your code.
eg, bit shifting too far, loading from uninitialised memory, divide by
zero, calling a function with the wrong ABI...
There are plenty of optimizations that will detect this undefined behaviour
and replace it with 'undef'.
Without seeing your code, we can't tell you exactly why this is happening.
On Wed, Aug 26, 2015 at 4:52 AM, Xiangyang Guo via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Thanks for reply.
> First, I use Clang to compile my source code without any optimization so
> that I get one .bc file, in which there is no 'undef' showing up. Then, I
> use opt to optimize the IR. So I assume things are correct and the 'undef'
> is introduced to satisfy the syntax of phi node, as you mentioned. But I
> really don't want this 'undef' in IR. Do you have any idea to get rid of
> 'undef'? Thanks a lot.
> On Tue, Aug 25, 2015 at 3:16 PM, Krzysztof Parzyszek via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>> On 8/25/2015 2:09 PM, Xiangyang Guo via llvm-dev wrote:
>>> I'm using LLVM-3.8 (current SVN version) to optimize my code. After loop
>>> unrolling, I find there is 'undef' in the IR. For example,
>>> "/%.lcssa21.unr = phi double [ undef, %.lr.ph9 ], [ %13, %7 ]/". I have
>>> two questions:
>>> (1) Why this 'undef' is generated? Because before 'loop unrolling',
>>> there is no such 'undef'.
>> Most likely to satisfy the syntax of a phi node. If everything is
>> correct, that value will never be used. If things weren't exactly correct,
>> this may be a result of a load from an uninitialized memory, or something
>> like that.
>> (2) How LLVM backend deals with this 'undef'?
>> In general, undef will propagate itself through instructions. How it
>> will deal with this specific one, it's impossible to say without the
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
>> by The Linux Foundation
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev