[LLVMdev] Advice on CFG pre-analysis

Eli Friedman eli.friedman at gmail.com
Sat May 24 09:12:07 PDT 2008


On Fri, May 23, 2008 at 11:53 PM, Talin <viridia at gmail.com> wrote:
> In the language I am working on, there are cases where the call flow
> graph can affect the type of a variable. A simple example is a
> "nullable" type (a pointer which is allowed to be NULL), which can be
> converted into a non-nullable type via an if-test. So for example if x
> is nullable, and I test x != NULL, then inside the conditional block the
> type of x is no longer nullable. Nullable types behave slightly
> differently (and produce less efficient code) than non-nullable types.
> For example, a downcast to a nullable type is a dynamic cast (because if
> the cast fails, the result can be NULL), whereas a downcast to a
> non-nullable type throws an exception if the cast fails.

I'm not completely sure what you're trying to do here, but it seems
like you want some special statement that essentially introduces a new
variable with the non-nullable type for a child block. Something like
ifnonnull P = getPersonForName("Talin") { code that references P },
for a language with C-like syntax.

It doesn't make any sense to do this sort of thing at the LLVM level;
I doubt you really want  optimizers or flow-sensitive analysis messing
with the semantics of programs in your language.

-Eli



More information about the llvm-dev mailing list