Displaying 20 results from an estimated 196 matches for "reinterpret_cast".
2017 Jun 11
2
Force casting a Value*
On 11 June 2017 at 07:53, David Blaikie <dblaikie at gmail.com> wrote:
> Sounds like you're looking for reinterpret_cast: http://en.
> cppreference.com/w/cpp/language/reinterpret_cast
>
I tried cast<ConstInt>(vo), but that failed at run-time.
>
> On Sun, Jun 11, 2017 at 3:06 AM Dipanjan Das via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>>
>> I am trying to cast a V...
2012 Feb 15
3
[LLVMdev] We need better hashing
...Is type_traits?
>
> Ooops, this was a cut & paste error from FoldingSet.cpp.
> enum {
> BufferSize = 32,
>
> BufferSize is dead.
>
>
> /// Add a pointer value
> template<typename T>
> void add(const T *PtrVal) {
> addImpl(
> reinterpret_cast<const uint32_t *>(&PtrVal),
> reinterpret_cast<const uint32_t *>(&PtrVal + 1));
> }
>
> This violates TBAA rules and looks pretty dangerous to expose as public
> API. Is this really needed? Also, addImpl is dereferencing the pointers
> as uint32_t...
2012 Feb 15
0
[LLVMdev] We need better hashing
On Feb 14, 2012, at 10:47 PM, Talin wrote:
> /// Add a pointer value
> template<typename T>
> void add(const T *PtrVal) {
> addImpl(
> reinterpret_cast<const uint32_t *>(&PtrVal),
> reinterpret_cast<const uint32_t *>(&PtrVal + 1));
> }
>
> This violates TBAA rules and looks pretty dangerous to expose as public API. Is this really needed? Also, addImpl is dereferencing the pointers as uint32_t's, but...
2012 Feb 14
0
[LLVMdev] We need better hashing
...Support/type_traits.h"
Do you actually need all of these includes? PointerLikeTypeTraits doesn't seem necessary. Is type_traits?
enum {
BufferSize = 32,
BufferSize is dead.
/// Add a pointer value
template<typename T>
void add(const T *PtrVal) {
addImpl(
reinterpret_cast<const uint32_t *>(&PtrVal),
reinterpret_cast<const uint32_t *>(&PtrVal + 1));
}
This violates TBAA rules and looks pretty dangerous to expose as public API. Is this really needed? Also, addImpl is dereferencing the pointers as uint32_t's, but there is nothing th...
2013 Mar 13
0
[LLVMdev] PROPOSAL: struct-access-path aware TBAA
...struct-access-path aware TBAA, C::b1.a.x does not alias with
D::c.b2.a.x.
> without it, the 2 scalar accesses can alias since both have int type.
I browsed the 2012 standard for a while and I didn't see anything that
would make this illegal:
char *p = malloc(enough_bytes);
intptr_t x = reinterpret_cast<intptr_t>(p);
x += offsetof(C, b2);
D &vd = *reinterpret_cast<D*>(p);
C &vc = *reinterpret_cast<C*>(x);
vd.c.b2.a.x = 1; // ..accessing the same
int t = vc.b1.a.x; // ..storage
I don't think that the path through the type structure is really sufficient.
-Krzyszto...
2013 Mar 12
3
[LLVMdev] PROPOSAL: struct-access-path aware TBAA
On Mar 12, 2013, at 8:22 AM, Krzysztof Parzyszek wrote:
> What cases does this proposal solve that the current analyses don't? Do you have a motivating example?
Given
struct A {
int x;
int y;
};
struct B {
A a;
int z;
};
struct C {
B b1;
B b2;
};
struct D {
C c;
};
with struct-access-path aware TBAA, C::b1.a.x does not alias with D::c.b2.a.x.
2012 Feb 13
5
[LLVMdev] We need better hashing
On Mon, Feb 13, 2012 at 1:22 AM, Jay Foad <jay.foad at gmail.com> wrote:
> On 13 February 2012 00:59, Talin <viridia at gmail.com> wrote:
> > Here's my latest version of Hashing.h, which I propose to add to
> llvm/ADT.
> > Comments welcome and encouraged.
>
> > /// Adapted from MurmurHash2 by Austin Appleby
>
> Just out of curiosity, why not
2007 Mar 06
1
Errors compiling flac in Visual Studio Express 2005
...eturn' : cannot convert from 'wchar_t *' to 'T_CHAR *'
14> Message: 'The POSIX name for this item is deprecated. Instead,
use the ISO C++ conformant name: _unlink. See online help for details.'
15> Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast
15>c:\greenhouse\workspace\soundio\tool\flac_1.1.3\main\flac-1.1.3\src\plugin_winamp2\tagz.cpp(98)
: error C2664: 'wcsdup' : cannot convert parameter 1 from 'const T_CHAR *'
to 'const wchar_t *'
14>c:\greenhouse\workspace\soundio\...
2013 May 10
4
[LLVMdev] [cfe-dev] "load groups" IR feature to improve C++ devirtualization
...he pointer
> value held in 'p' is not updated. Copying that value into 'q' does not
> change the fact that the pointer value still refers to a non-existent
> object.
>
I'm actually okay with the simple copy not forming a new object pointer.
However, "Base *q = reinterpret_cast<Base*>(p);" really ought to.
It is unclear what, exactly, under the rules constitutes forming a valid
> pointer to the newly-constructed object except using the result of the
> new-expression itself. I think an explicit cast might, ignoring all
> "object-ness" of the...
2017 Jun 11
2
Force casting a Value*
...state.net>
wrote:
> On Sun, Jun 11, 2017 at 7:49 PM, Dipanjan Das via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>>
>>
>> On 11 June 2017 at 07:53, David Blaikie <dblaikie at gmail.com> wrote:
>>
>>> Sounds like you're looking for reinterpret_cast: http://en.cp
>>> preference.com/w/cpp/language/reinterpret_cast
>>>
>>
>> I tried cast<ConstInt>(vo), but that failed at run-time.
>>
>
> That is not the same as reinterpret_cast<int64>(some_value_star).
>
None of the following work.
Value...
2010 Aug 19
2
[LLVMdev] using external functions from llvm
...seem to be working for me.
I have a function:
llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const
std::vector<llvm::GenericValue>& args)
{
llvm_object_structure* result = new llvm_object_structure;
result->typeIdx = TypeSystem::number;
result->data = reinterpret_cast<unsigned char*>(new
double(args[0].DoubleVal));
llvm::GenericValue gv;
gv.PointerVal = reinterpret_cast<void*>(result);
return gv;
}
defined in an extern "C" block. I add it as a symbol with:
llvm::sys::DynamicLibrary::AddSymbol("lle_X_create_number_object",(...
2010 May 20
0
[LLVMdev] Win32 COFF Support
...r commit-worthy is a round of reviews and some tests
showing that basic functionality works.
Minor comments:
1. Is it possible to allocate extra memory with coff::symbol instead
of using std::string and std::vector as class members? The extra
allocations can add up.
2. For the following bit:
+ reinterpret_cast <uint32_t &> (Section->Symbol->Aux [0]) =
Section->Header.SizeOfRawData;
+ reinterpret_cast <uint16_t &> (Section->Symbol->Aux [4]) =
Section->Header.NumberOfRelocations;
+ reinterpret_cast <uint16_t &> (Section->Symbol->Aux [6]) =
Section...
2013 May 10
0
[LLVMdev] [cfe-dev] "load groups" IR feature to improve C++ devirtualization
...fferent, the pointer value held in 'p' is not updated. Copying that value into 'q' does not change the fact that the pointer value still refers to a non-existent object.
>
> I'm actually okay with the simple copy not forming a new object pointer. However, "Base *q = reinterpret_cast<Base*>(p);" really ought to.
Yes, I agree that it ought to.
> It is unclear what, exactly, under the rules constitutes forming a valid pointer to the newly-constructed object except using the result of the new-expression itself. I think an explicit cast might, ignoring all "ob...
2012 Feb 15
2
[LLVMdev] We need better hashing
...e includes? PointerLikeTypeTraits doesn't
> seem necessary. Is type_traits?
>
> enum {
> BufferSize = 32,
>
> BufferSize is dead.
>
>
> /// Add a pointer value
> template<typename T>
> void add(const T *PtrVal) {
> addImpl(
> reinterpret_cast<const uint32_t *>(&PtrVal),
> reinterpret_cast<const uint32_t *>(&PtrVal + 1));
> }
>
> This violates TBAA rules and looks pretty dangerous to expose as public API.
> Is this really needed? Also, addImpl is dereferencing the pointers as
> uint32_t...
2017 Jun 11
2
Force casting a Value*
I am trying to cast a Value* irrespective of its underlying subclass to
uint64 and pass it on to a method as an argument.
if (StoreInst *store_inst = dyn_cast<StoreInst>(&I)) {
Value* vo = store_inst->getValueOperand();
uint64 value = /* cast vo to unsigned int 64 bit */
func(value);
}
How can I force
2013 May 10
0
[LLVMdev] [cfe-dev] "load groups" IR feature to improve C++ devirtualization
...fferent, the pointer value held in 'p' is not updated. Copying that value into 'q' does not change the fact that the pointer value still refers to a non-existent object.
>
> I'm actually okay with the simple copy not forming a new object pointer. However, "Base *q = reinterpret_cast<Base*>(p);" really ought to.
>
> It is unclear what, exactly, under the rules constitutes forming a valid pointer to the newly-constructed object except using the result of the new-expression itself. I think an explicit cast might, ignoring all "object-ness" of the sour...
2011 Jan 07
1
[LLVMdev] Problem returning structures by value from C
I have a simple structure in my program:
struct pair { double value; int32_t type; };
Also I have 2 functions, which are called from LLVM code:
extern "C" void dump(pair s) {
unsigned char *p = reinterpret_cast<unsigned char *>(&s);
printf("#dump, %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9], p[10], p[11]);
}
extern "C" pair set() {
pair ret = { 0, 3 };
unsigned char *p = reinterpret_cast...
2016 Apr 27
4
RFC: LLD symbol table redesign
...s of SymbolBody stored directly in the Symbol object without a level of
indirection. The class definitions would roughly look like this:
struct Symbol {
uint8_t Binding;
unsigned Visibility : 2;
// ...
char Body[Max]; // Max is the maximum size of a SymbolBody
SymbolBody *body() { return reinterpret_cast<SymbolBody *>(Body); }
};
class SymbolBody {
const unsigned SymbolKind : 8;
// …
Symbol &symbol() {
return *reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
offsetof(Symbol, Body));
}
};
class Defined : public SymbolBody {
...
};
As we load symbols...
2010 Aug 19
3
[LLVMdev] using external functions from llvm
...e a function:
>
> llvm::GenericValue lle_X_create_number_object(llvm::FunctionType* ft, const
> std::vector<llvm::GenericValue>& args)
> {
> llvm_object_structure* result = new llvm_object_structure;
> result->typeIdx = TypeSystem::number;
> result->data = reinterpret_cast<unsigned char*>(new
> double(args[0].DoubleVal));
> llvm::GenericValue gv;
> gv.PointerVal = reinterpret_cast<void*>(result);
> return gv;
> }
>
> defined in an extern "C" block. I add it as a symbol with:
>
>
> llvm::sys::DynamicLibrary::Ad...
[llvm] r322838 - [ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
2018 Jan 24
2
[llvm] r322838 - [ADT] Split optional to only include copy mechanics and dtor for non-trivial types.
...}
>
> + ~OptionalStorage() { reset(); }
> +
> void reset() {
> if (hasVal) {
> - (**this).~T();
> + (*getPointer()).~T();
> hasVal = false;
> }
> }
>
> - const T *getPointer() const {
> - assert(hasVal);
> - return reinterpret_cast<const T *>(storage.buffer);
> - }
> T *getPointer() {
> assert(hasVal);
> return reinterpret_cast<T *>(storage.buffer);
> }
> - const T &getValue() const LLVM_LVALUE_FUNCTION {
> + const T *getPointer() const {
> assert(hasVal);
> -...