[LLVMdev] Undefined behavior in Operator class?

Sean Silva silvas at purdue.edu
Sun Oct 7 09:47:15 PDT 2012


> I tried removing the method and rebuilding.  The resulting compilation errors were easily fixed by changing the few occurrences in:
>         include/llvm/Support/PatternMatch.h
>         lib/Analysis/BasicAliasAnalysis.cpp
>         lib/Analysis/ScalarEvolution.cpp
>         lib/Analysis/ValueTracking.cpp
>         lib/CodeGen/ScheduleDAGInstrs.cpp
>         lib/CodeGen/SelectionDAG/FastISel.cpp
> to use the static variant of Operator::getOpcode().  (This was with 3.1; trunk may be different.)

That seems like probably the best short term solution. It doesn't fix
the core problem though, which is that Instruction and ConstantExpr
are getting cast<>'d to Operator (or one of its subclasses), in an
illegal fashion.

> I suppose one could also modify the non-static method to invoke the static one, passing "this" as the argument, but that just doesn't feel right...

That would still be UB.

-- Sean Silva

On Sun, Oct 7, 2012 at 12:32 PM, Caldarale, Charles R
<Chuck.Caldarale at unisys.com> wrote:
>> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Sean Silva
>> Subject: Re: [LLVMdev] Undefined behavior in Operator class?
>
>> > > In this function, the `this` pointer is not pointing at an Operator
>> > > object. That's undefined behavior, right?
>
>> > Yes.
>
>> Well then I guess the next step is how to fix it.
>
> I tried removing the method and rebuilding.  The resulting compilation errors were easily fixed by changing the few occurrences in:
>         include/llvm/Support/PatternMatch.h
>         lib/Analysis/BasicAliasAnalysis.cpp
>         lib/Analysis/ScalarEvolution.cpp
>         lib/Analysis/ValueTracking.cpp
>         lib/CodeGen/ScheduleDAGInstrs.cpp
>         lib/CodeGen/SelectionDAG/FastISel.cpp
> to use the static variant of Operator::getOpcode().  (This was with 3.1; trunk may be different.)
>
> I suppose one could also modify the non-static method to invoke the static one, passing "this" as the argument, but that just doesn't feel right...
>
>  - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>



More information about the llvm-dev mailing list