[llvm-commits] Enhance C bindings with volatile load/store

Chris Lattner clattner at apple.com
Fri Feb 24 17:52:38 PST 2012


On Feb 24, 2012, at 2:56 AM, Yiannis Tsiouris wrote:

>> What do you think of adding a "getVolatile/setVolatile" style of function to the C API instead?  That seems more general purpose.
>> 
>> -Chris
>>   
> I attach a solution with "getVolatile/setVolatile" but I'm not sure if my handling of LoadInst vs. StoreInst is compatible with the LLVM standards. Thus, I apologize if my patch hurts your eyes... Any suggestion is very much welcome!

This is close, but won't quite work.  I'd suggest something along the lines of:

  Value *P = unwrap<Value>(MemAccessInst);
  if (LoadInst *LI = dyn_cast<LoadInst>(P))
    return LI->isVolatile();
  return cast<StoreInst>(P)->isVolatile();

The important thing here is that "unwrap" crashes if passed something of the wrong type.

-Chris



More information about the llvm-commits mailing list