[LLVMdev] Overzealous PromoteCastOfAllocation
Chris Lattner
clattner at apple.com
Sat Oct 4 17:36:06 PDT 2008
On Sep 23, 2008, at 11:52 AM, Dan Gohman wrote:
> On Sep 23, 2008, at 4:16 AM, Matthijs Kooijman wrote:
>>
>>> and then does a load or store at the higher alignment, is
>>> invoking undefined behavior. The alignment attribute on a load or
>>> store
>>> is an assertion about the actual alignment of the memory.
>> Should this undefined behaviour be caught by the verifier, or is it
>> ok for it
>> to exist?
>
> I don't think so. It's not the Verifier's job to diagnose undefined
> behavior. The IR in this case is valid, so the verifier should
> accept it.
Right.
> For better or worse, stores to null pointers are pretty common in
> LLVM IR. The most common source of these is unreachable code, and
> bugpoint, but those are important use cases :-).
An important thing to consider is that valid and well defined C code
can expose cases of undefined behavior in unreachable code after
optimizations. It is fine to turn these cases into "unreachable"
instructions (which is undefined by definition!) but the compiler
can't reject or crash on it.
> However, it might be interesting to have a separate
> undefined-behavior-detector pass. An LLVM pass wouldn't likely be
> usable as an user-level bug finder; clang's static analysis is
> much better positioned to do that kind of thing. But an LLVM pass
> would be able to find bugs in front-ends and optimization passes.
Right. From a user perspective, such a tool wouldn't be able to
report back to the user with enough fidelity to give them any info on
how to fix the problem.
-Chris
More information about the llvm-dev
mailing list