+ * Finds the base address of an address by skipping Sel's and address
+ * calculation.
+ *
+ * @param adr the address
+ * @param pEnt points to the base entity if any
+ */
+static ir_node *find_base_adr(ir_node *ptr, ir_entity **pEnt) {
+ ir_entity *ent = NULL;
+ assert(mode_is_reference(get_irn_mode(ptr)));
+
+ for (;;) {
+ if (is_Sel(ptr)) {
+ ent = get_Sel_entity(ptr);
+ ptr = get_Sel_ptr(ptr);
+ }
+ else if (is_Add(ptr)) {
+ ir_node *left = get_Add_left(ptr);
+ if (mode_is_reference(get_irn_mode(left)))
+ ptr = left;
+ else
+ ptr = get_Add_right(ptr);
+ ent = NULL;
+ } else if (is_Sub(ptr)) {
+ ptr = get_Sub_left(ptr);
+ ent = NULL;
+ } else {
+ *pEnt = ent;
+ return ptr;
+ }
+ }
+}
+
+/**
+ * Check if a given pointer represents non-local memory.
+ */
+static void check_ptr(ir_node *ptr, wlk_env *env) {
+ ir_storage_class_class_t sc;
+ ir_entity *ent;
+
+ /* still alias free */
+ ptr = find_base_adr(ptr, &ent);
+ sc = classify_pointer(current_ir_graph, ptr, ent);
+ if (sc != ir_sc_localvar && sc != ir_sc_malloced) {
+ /* non-local memory access */
+ env->only_local_mem = 0;
+ }
+}
+
+/**
+ * Post walker: shift all parameter indexes