[cfe-dev] Uninitialized Variables Analysis crashing

João Paulo Labegalini de Carvalho via cfe-dev cfe-dev at lists.llvm.org
Sun Sep 23 14:39:29 PDT 2018


Hi,

I have implemented a new Stmt in clang which given

__speculate {
 // user code
}

generates LLVM IR equivalent to as if the following code was given:

jmp_buf __setjmp_buf;
int __setjmp_status = setjmp(__setjmp_buf);
unsigned int __spec_mode = __spec_begin(__setjmp_buf, __setjmp_status);
if (__spec_mode == SW) {
  // unmodified user code
} else
 // unmodified user code
}

However, if UninitializedVariablesAnalysis is enabled, clang crashes
at runOnBlock function (lib/Analysis/UninitializedValues.cpp). If I disable
it via -Wno-uninitialized, the code generated runs flawlessly and works as
expected.

By adding some "->dumps()" calls I was able to discover that the crash
happens while analyzing:

unsigned int __spec_mode = __spec_begin(__setjmp_buf, __setjmp_status);

The UninitializedVariables Analysis generates the following classifications
before crashing:


   - DeclRefExpr 0x22a1940 'unsigned int (jmp_buf *, int)' Function
   0x22a17d0 '*__spec_begin*' 'unsigned int (jmp_buf *, int)' *as
   "ClassifyRefs::Ignore"*
   - DeclRefExpr 0x22a1680 'jmp_buf':'struct __jmp_buf_tag [1]' Var
   0x22a1248 '*__setjmp_buf*' 'jmp_buf':'struct __jmp_buf_tag [1]' *as
   "ClassifyRefs::Ignore"*
   - DeclRefExpr 0x22a16c8 'int' Var 0x22a12a8 '*__setjmp_ret*' 'int' *as
   "ClassifyRefs::Use"*

So it seems that the analysis successfully classifies the call and both of
its arguments, but crashes while analyzing the *__spec_mode* variable.

Any guesses on what I am doing wrong?

-- 
João Paulo L. de Carvalho
Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
jaopaulolc at gmail.com
joao.carvalho at ic.unicamp.br
j160924 at dac.unicamp.br
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180923/7949324b/attachment.html>


More information about the cfe-dev mailing list