[llvm-commits] [llvm] r71783 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Eli Friedman eli.friedman at gmail.com
Thu May 14 11:59:02 PDT 2009


On Thu, May 14, 2009 at 11:52 AM, Dale Johannesen <dalej at apple.com> wrote:
>
> On May 14, 2009, at 11:45 AMPDT, Eli Friedman wrote:
>
>> On Thu, May 14, 2009 at 11:41 AM, Dale Johannesen <dalej at apple.com>
>> wrote:
>>> +        Value *V2 = I->getOperand(0)->getUnderlyingObject();
>>> +        if (V2) {
>>> +          GlobalVariable* GV = dyn_cast<GlobalVariable>(V2);
>>> +          if (GV && GV->hasExternalWeakLinkage())
>>> +            return false;
>>> +        }
>>
>> Ah, hmm, I'm not sure how I missed this when I looked at it
>> originally, but it's unsafe to continue if V2 or GV is null.  In those
>> cases, you have no clue what the pointer points at.
>
> A variable base you mean?  That wouldn't be a Constant, would it?  Can
> you give an example that would break?

Somewhat silly example, but something like the following leads to an
unsafe constant:

__attribute((weak)) extern int x;
int a() { return *(int*)(((unsigned long)&x)/2*2); }

-Eli




More information about the llvm-commits mailing list