__builtin_object_size
| Bugzilla Link | 4380 |
| Resolution | FIXED |
| Resolved on | Mar 01, 2010 21:36 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @echristo |
Extended Description
In this example, builtin_object_size is not lowered by llvm-gcc.
typedef struct _MyFoo { int x, y; } MyFoo; void foobar() { int y; #pragma omp parallel for schedule(dynamic,4) for (y=0; y < 64; y++) { MyFoo *p, *q; __builtin___memcpy_chk (q, p, sizeof(p), __builtin_object_size (q, 0)); } }
Fixed now.
Crap. Forgot the openmp. Not fixed.
I fixed this a while back.
The difference is caused by this change in pop_gimplify_context:
#ifndef ENABLE_LLVM /* LLVM wants to know about gimple formal temps. */ for (t = c->temps; t ; t = TREE_CHAIN (t)) DECL_GIMPLE_FORMAL_TEMP_P (t) = 0; #else t = 0; #endif
In this case, failing to clear DECL_GIMPLE_FORMAL_TEMP_P for the symbol to which the result of the builtin_object_size call is assigned, results in the "val_only" bit being clear during the tree walk of the call, hence the gimplifier thinks it needs to put the builtin_object_size function symbol into a temp as well. Logically it seems the val_only bit should be set by the tree walker when stepping into the callee node of the call, but I'm sure that would have wide ranging effects....
It is the omp lowering pass; it does not do this in gcc-4.2, and the file omp-low.c, which contains that pass, is identical. I guess the thing to do is step through them in parallel. (The magic flag is spelled -fopenmp, btw, if you're still reading you probably knew that).
Hm, the gcc earlier phases have broken down the call into
t = &builtin_object_size; call t(...)
That's vicious. Probably the right idea is to find what's doing that and stop it.
Ah, additional data. You're right, it's not.
Are you sure it is lowered when -fopnemp is used ?
Actually, it is lowered to -1, and then the memcpy_chk expansion decides it is OK to lower that to a plain memcpy since nothing about the object size is known, like this: call void @llvm.memcpy.i32(i8* %2, i8* %3, i32 4, i32 1) The final 1 is alignment, not anything to do with object-size. I think this is OK.
This is easy to fix. It should be lowered to -1 / 0 when the size is unknown.