[dragonegg] r182243 - Arrange for the gcc-4.8 iteration style to work with earlier versions of gcc too
Duncan Sands
baldrick at free.fr
Mon May 20 02:35:42 PDT 2013
Author: baldrick
Date: Mon May 20 04:35:42 2013
New Revision: 182243
URL: http://llvm.org/viewvc/llvm-project?rev=182243&view=rev
Log:
Arrange for the gcc-4.8 iteration style to work with earlier versions of gcc too
and use this for iterating over the alias_pairs array.
Modified:
dragonegg/trunk/include/dragonegg/Trees.h
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/include/dragonegg/Trees.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Trees.h?rev=182243&r1=182242&r2=182243&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Trees.h (original)
+++ dragonegg/trunk/include/dragonegg/Trees.h Mon May 20 04:35:42 2013
@@ -152,7 +152,7 @@ template <typename T, typename A> class
};
#define INSTANTIATE_VECTOR(TT) \
- template<> class vec<TT, va_gc> { \
+ template <> class vec<TT, va_gc> { \
VEC(TT, gc) & v; \
public: \
vec(VEC(TT, gc) & V) : v(V) {} \
@@ -160,6 +160,9 @@ template <typename T, typename A> class
bool is_empty() const { return VEC_empty(TT, &v); } \
unsigned length() const { return VEC_length(TT, &v); } \
TT &operator[](unsigned i) const { return *VEC_index(TT, &v, i); } \
+ bool iterate(unsigned ix, TT **ptr) const { \
+ return VEC_iterate(TT, &v, ix, *ptr); \
+ } \
}
#endif
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=182243&r1=182242&r2=182243&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Mon May 20 04:35:42 2013
@@ -1754,6 +1754,10 @@ static void emit_varpool_weakrefs() {
}
#endif
+#if (GCC_MINOR < 8)
+INSTANTIATE_VECTOR(alias_pair);
+#endif
+
/// llvm_emit_globals - Output GCC global variables, aliases and asm's to the
/// LLVM IR.
static void llvm_emit_globals(void * /*gcc_data*/, void * /*user_data*/) {
@@ -1811,9 +1815,12 @@ static void llvm_emit_globals(void * /*g
// Emit any aliases that aren't represented in cgraph or varpool, for example
// a function that aliases a variable or a variable that aliases a function.
- alias_pair *p;
- for (unsigned i = 0; VEC_iterate(alias_pair, alias_pairs, i, p); i++)
- emit_alias(p->decl, p->target);
+ if (alias_pairs) {
+ alias_pair *p;
+ const vec<alias_pair, va_gc> &pairs = *alias_pairs;
+ for (unsigned i = 0; pairs.iterate(i, &p); i++)
+ emit_alias(p->decl, p->target);
+ }
}
static void InlineAsmDiagnosticHandler(const SMDiagnostic &D, void */*Data*/,
More information about the llvm-commits
mailing list