[llvm-commits] [llvm] r147560 - in /llvm/trunk: include/llvm/Analysis/ValueTracking.h lib/Analysis/ValueTracking.cpp
Chris Lattner
clattner at apple.com
Thu Jan 5 09:36:27 PST 2012
On Jan 5, 2012, at 12:25 AM, Duncan Sands wrote:
> Hi Dan,
>
>> Generalize isSafeToSpeculativelyExecute to work on arbitrary
>> Values, rather than just Instructions, since it's interesting
>> for ConstantExprs too.
>
> since constants are not executed, what does this mean? I notice that all
> constants results in 'false', i.e. not safe to speculatively execute. Why
> is that?
Constant expressions can potentially trap (e.g. divide with a RHS that turns out to be zero). This is why they have the canTrap() method. This is annoying and should be fixed someday, but until then this is a reasonable thing to do. The dyncast to Operator handles both instructions and constantexprs.
-Chris
>
> Ciao, Duncan.
>
>>
>> Modified:
>> llvm/trunk/include/llvm/Analysis/ValueTracking.h
>> llvm/trunk/lib/Analysis/ValueTracking.cpp
>>
>> Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=147560&r1=147559&r2=147560&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original)
>> +++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Wed Jan 4 17:01:09 2012
>> @@ -174,7 +174,7 @@
>> /// the correct dominance relationships for the operands and users hold.
>> /// However, this method can return true for instructions that read memory;
>> /// for such instructions, moving them may change the resulting value.
>> - bool isSafeToSpeculativelyExecute(const Instruction *Inst,
>> + bool isSafeToSpeculativelyExecute(const Value *V,
>> const TargetData *TD = 0);
>>
>> } // end namespace llvm
>>
>> Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=147560&r1=147559&r2=147560&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
>> +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Jan 4 17:01:09 2012
>> @@ -1879,8 +1879,12 @@
>> return true;
>> }
>>
>> -bool llvm::isSafeToSpeculativelyExecute(const Instruction *Inst,
>> +bool llvm::isSafeToSpeculativelyExecute(const Value *V,
>> const TargetData *TD) {
>> + const Operator *Inst = dyn_cast<Operator>(V);
>> + if (!Inst)
>> + return false;
>> +
>> for (unsigned i = 0, e = Inst->getNumOperands(); i != e; ++i)
>> if (Constant *C = dyn_cast<Constant>(Inst->getOperand(i)))
>> if (C->canTrap())
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list