Compiling the following simple function causes a segmentation fault in the c6000 optimizer:
void AO_findMinMax(Int16 *restrict piImage, Int16 *piMin, Int16 *piMax)
{
/* Find min/max of search area in image */
Int16 min = 32767;
Int16 max = -32767;
Int16 x, y;
Int16 temp;
for(y = (10); y < (470-((30)+(30)+(30))) + ((30)+(30)+(30)); y++)
{
for(x = (100); x < (600-((30)+(50)+(30))) + ((30)+(50)+(30)); x++)
{
temp = piImage[x];
if(temp < min)
{
min = temp;
}
}
}
*piMin = min;
*piMax = max;
}
If I change "min = temp;" to "max = temp;" it compiles cleanly.
The preprocessed file is attached
/*
* Copyright (c) 2008 Texas Instruments. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License
* v. 1.0 which accompanies this distribution. The Eclipse Public License is
* available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
* Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Texas Instruments - initial implementation
* */
/*****************************************************************************/
/* stdarg.h v7.3.2 */
/* */
/* Copyright (c) 1993-2011 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* */
/* Neither the name of Texas Instruments Incorporated nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*****************************************************************************/
typedef char *va_list;
/*****************************************************************************/
/* VA_END - Reclaim resources used by varargs handling. */
/* */
/* No action needed */
/*****************************************************************************/
/*****************************************************************************/
/* VA_START - Set up the va_list pointer. */
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/* COFF ABI convention: */
/* - va_list is kept aligned to 4 bytes. */
/* - va_list pointer points one word beyond the start of the last argument. */
/*---------------------------------------------------------------------------*/
/*****************************************************************************/
/* VA_ARG - Return the next argument, adjust va_list pointer */
/* */
/* Some arguments passed by value are turned into pass-by-reference by */
/* making a temporary object and passing a pointer to this temporary. For */
/* such an argument (indicated by __va_argref(_type)) the actual argument */
/* passed is a pointer, so it must be dealt with specially. */
/* */
/* When an argument is larger than the maximum alignment (8 bytes for double */
/* or long long), we only align to 8 bytes. */
/*****************************************************************************/
/*---------------------------------------------------------------------------*/
/* What happens on every va_arg(_ap, _type) call is: */
/* 1) Align the value of _ap (the va_list pointer) appropriately for _type */
/* (the requested type). */
/* 2) Increment _ap appropriately for _type. */
/* 3) Return the value desired by dereferencing _ap. */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* The big- and little-endian variants are different only because we are */
/* trying to support the case of the user asking for "char" or "short", */
/* which is actually undefined behavior (See ISO/IEC 9899:1999 7.15.1.1), */
/* but we are trying to be friendly. */
/*---------------------------------------------------------------------------*/
/*****************************************************************************/
/* stddef.h v7.3.2 */
/* */
/* Copyright (c) 1993-2011 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* */
/* Neither the name of Texas Instruments Incorporated nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*****************************************************************************/
typedef int ptrdiff_t;
typedef unsigned size_t;
typedef unsigned short wchar_t;
/*-----------------------------------------------------------------------*/
/* Define _win_t, for compiling GCC libraries with the TI compiler. */
/* GCC's library (newlib) expects wint_t to be defined here, in stddef.h,*/
/* which is arguably incorrect, but we go along for compatibility. */
/* This is outside the _STDDEF guard in case this file has already */
/* been included without __need_wint_t. */
/*-----------------------------------------------------------------------*/
/* macros to simplify "stringification" and computed includes */
/* TitleCase standard types */
typedef char xdc_Char;
typedef unsigned char xdc_UChar;
typedef short xdc_Short;
typedef unsigned short xdc_UShort;
typedef int xdc_Int;
typedef unsigned int xdc_UInt;
typedef long xdc_Long;
typedef unsigned long xdc_ULong;
typedef float xdc_Float;
typedef double xdc_Double;
typedef long double xdc_LDouble;
typedef size_t xdc_SizeT;
typedef va_list xdc_VaList;
/* Generic Extended Types */
typedef unsigned short xdc_Bool; /* boolean flag */
typedef void *xdc_Ptr; /* data pointer */
typedef char *xdc_String; /* null terminated string */
/* we intentionally omit arguments from Fxn to indicate that it can have
* any (or none). Unfortunately this causes gcc to emit warnings when
* -Wstrict-prototypes is used. Newer gcc's support a pragma that
* may work around this:
*
* #pragma GCC diagnostic ignored "-Wstrict-prototype"
*/
typedef int (*xdc_Fxn)(); /* function pointer */
/*
* Import the target-specific std.h
*/
/*
* Copyright (c) 2008 Texas Instruments and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Texas Instruments - initial implementation
*
* */
/*
* ======== ti/targets/std.h ========
* Standard types for supported TI compilers
*
*/
/* include target-specific "portable" macros */
/*
* Copyright 2011 by Texas Instruments Incorporated.
*
*/
/*
* ======== C674.h ========
* DO NOT MODIFY: This header is generated from stddef.xdt
*
* This header contains target-specific definitions of target-independent
* macros required by the ITarget interface. These definitions allow C/C++
* sources to portably compile for multiple targets (using #ifdef ...).
*/
/*
* ======== ti_targets_C674 ========
* This macro identifies the specific target being used. This macro should
* probably be avoided in portable sources.
*/
/*
* ======== xdc_target__isaCompatible_* macros ========
* The following definitions enable clients to conditionally compile for any
* compatible subset of the actual target ISA.
*/
/*
* ======== xdc_target__isa_674 ========
* This macro identifies the specific target ISA for which we are being
* compiled.
*/
/*
* ======== xdc_target__{big|little}Endian ========
* The following macro enables clients to portably compile for big or little
* endian targets.
*/
/*
* ======== xdc_target__os_undefined ========
* The following macro enables clients to portably compile for target specific
* OS; e.g., Linux, Solaris, Windows, undefined.
*/
/*
* ======== xdc_target__sizeof_ ========
* The following macros enable clients to portably determine type sizes
* within #ifdef blocks; sizeof() can't be used and the definitions in
* stdint.h are not available to C++ clients (unless the special macro
* __STDC_LIMIT_MACROS is defined).
*/
/*
* ======== xdc_target__alignof_ ========
* The following macros enable clients to portably determine type alignment
* within #ifdef blocks; even if provided by the compiler, alignof() can't
* be used in pre-processor statements.
*/
/*
* ======== xdc_target__bitsPerChar ========
* The number of bits in a char. This macro allow one to determine the
* precise number of bits in any of the standard types (whose sizes are
* expressed as a number of chars).
*/
/*
* @(#) ti.targets; 1, 0, 3,460; 7-12-2011 21:04:02; /db/ztree/library/trees/xdctargets/xdctargets-e06x/src/ xlibrary
*/
/*****************************************************************************/
/* STDINT.H v7.3.2 */
/* */
/* Copyright (c) 2002-2011 Texas Instruments Incorporated */
/* http://www.ti.com/ */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are permitted provided that the following conditions */
/* are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the */
/* distribution. */
/* */
/* Neither the name of Texas Instruments Incorporated nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*****************************************************************************/
/* 7.18.1.1 Exact-width integer types */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int40_t int40_t;
typedef unsigned __int40_t uint40_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
/* 7.18.1.2 Minimum-width integer types */
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
typedef int40_t int_least40_t;
typedef uint40_t uint_least40_t;
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
/* 7.18.1.3 Fastest minimum-width integer types */
typedef int32_t int_fast8_t;
typedef uint32_t uint_fast8_t;
typedef int32_t int_fast16_t;
typedef uint32_t uint_fast16_t;
typedef int32_t int_fast32_t;
typedef uint32_t uint_fast32_t;
typedef int40_t int_fast40_t;
typedef uint40_t uint_fast40_t;
typedef int64_t int_fast64_t;
typedef uint64_t uint_fast64_t;
/* 7.18.1.4 Integer types capable of holding object pointers */
typedef int intptr_t;
typedef unsigned int uintptr_t;
/* 7.18.1.5 Greatest-width integer types */
typedef long long intmax_t;
typedef unsigned long long uintmax_t;
/*
According to footnotes in the 1999 C standard, "C++ implementations
should define these macros only when __STDC_LIMIT_MACROS is defined
before <stdint.h> is included."
*/
/* 7.18.2 Limits of specified width integer types */
/* 7.18.3 Limits of other integer types */
/* 7.18.4.1 Macros for minimum-width integer constants */
/*
There is a defect report filed against the C99 standard concerning how
the (U)INTN_C macros should be implemented. Please refer to --
http://wwwold.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_209.htm
for more information. These macros are implemented according to the
suggestion given at this web site.
*/
/* 7.18.4.2 Macros for greatest-width integer constants */
typedef int xdc_Arg; /* deprecated, but compatible with BIOS 5.x */
/*
* xdc__LONGLONG__ indicates if compiler supports 'long long' type
* xdc__BITS<n> __ indicates if compiler supports 'uint<n>_t' type
*/
/*
* int40_t types are supported for ELF in 7.2.0A10197 and later.
* This ifdef should be removed when the cut over to 7.2 is complete.
*/
/*
* ======== [U]Int<n> ========
*/
typedef int_least8_t xdc_Int8;
typedef uint_least8_t xdc_UInt8;
typedef int_least16_t xdc_Int16;
typedef uint_least16_t xdc_UInt16;
typedef int_least32_t xdc_Int32;
typedef uint_least32_t xdc_UInt32;
typedef int_least64_t xdc_Int64;
typedef int_least64_t xdc_UInt64;
typedef int_least40_t xdc_Int40;
typedef uint_least40_t xdc_UInt40;
/* the following unqualified names are here because 40-bit types are not
* supported by xdc/std.h
*/
typedef xdc_Int40 Int40;
typedef xdc_UInt40 UInt40;
/*
* ======== Bits<n> ========
*/
typedef uint8_t xdc_Bits8;
typedef uint16_t xdc_Bits16;
typedef uint32_t xdc_Bits32;
typedef uint64_t xdc_Bits64;
/*
* ======== [UI]Arg ========
*/
typedef intptr_t xdc_IArg;
typedef uintptr_t xdc_UArg;
/*
* ======== restrict ========
*/
/*
* ======== ti_targets_mkPragma ========
*/
/*
* ======== xdc__META ========
*/
/*
* ======== __ti__ ========
* These symbols are used by RTSC tools to indicate presence/absence of
* assorted #pragma options in TI compiler.
*/
/*
* @(#) ti.targets; 1, 0, 3,460; 7-12-2011 21:04:03; /db/ztree/library/trees/xdctargets/xdctargets-e06x/src/ xlibrary
*/
/* Each modules' internal header file defines 'module' as
* xdc__MODOBJADDR__(Module__state__V), where Module__state__V is the actual
* object where the module state is kept. For most targets, the default macro
* given here results in the construct '(&Module__state__V)->field', when the
* expression 'module->field' is used. Compilers then generate the code that
* doesn't dereference a pointer, but puts the address of the field in the
* code.
* The targets that need to do something different can define
* xdc__MODOBJADDR__ in std.h for their target package.
*/
/* Long Long Types */
typedef long long xdc_LLong;
typedef unsigned long long xdc_ULLong;
/* Arg to Ptr and Fxn conversion operators
*
* Individual targets may override these definitions in the event
* that compilers issue warnings about shortening of an Arg to a pointer,
* for example.
*/
static inline xdc_Ptr xdc_iargToPtr(xdc_IArg a) { return ((xdc_Ptr)a); }
static inline xdc_Ptr xdc_uargToPtr(xdc_UArg a) { return ((xdc_Ptr)a); }
static inline xdc_Fxn xdc_iargToFxn(xdc_IArg a) { return ((xdc_Fxn)a); }
static inline xdc_Fxn xdc_uargToFxn(xdc_UArg a) { return ((xdc_Fxn)a); }
/*
* functions to convert a single precision float to an arg
* Here assumption is that sizeof(Float) <= sizeof(IArg);
*/
typedef union xdc_FloatData {
xdc_Float f;
xdc_IArg a;
} xdc_FloatData;
static inline xdc_IArg xdc_floatToArg(xdc_Float f)
{
xdc_FloatData u;
u.f = f;
return (u.a);
}
static inline xdc_Float xdc_argToFloat(xdc_IArg a)
{
xdc_FloatData u;
u.a = a;
return (u.f);
}
/* restrict keyword */
/* Unprefixed Aliases */
typedef xdc_Char Char;
typedef xdc_UChar UChar;
typedef xdc_Short Short;
typedef xdc_UShort UShort;
typedef xdc_Int Int;
typedef xdc_UInt UInt;
typedef xdc_Long Long;
typedef xdc_ULong ULong;
typedef xdc_LLong LLong;
typedef xdc_ULLong ULLong;
typedef xdc_Float Float;
typedef xdc_Double Double;
typedef xdc_LDouble LDouble;
typedef xdc_SizeT SizeT;
typedef xdc_VaList VaList;
typedef xdc_IArg IArg;
typedef xdc_UArg UArg;
typedef xdc_Bool Bool;
typedef xdc_Int8 Int8;
typedef xdc_Int16 Int16;
typedef xdc_Int32 Int32;
typedef xdc_Fxn Fxn;
typedef xdc_Ptr Ptr;
typedef xdc_String String;
typedef xdc_UInt8 UInt8;
typedef xdc_UInt16 UInt16;
typedef xdc_UInt32 UInt32;
/* DEPRECATED Aliases */
/* xdc_Arg is defined only in ti/targets/std.h; use IArg and UArg instead */
typedef xdc_Arg Arg;
typedef xdc_UInt8 Uint8;
typedef xdc_UInt16 Uint16;
typedef xdc_UInt32 Uint32;
typedef xdc_UInt Uns;
/*
* ======== optional types ========
* The following types are not always defined for all targets
*/
typedef xdc_Int64 Int64;
typedef xdc_UInt64 UInt64;
/* The following exact size types are not required by C99 and may not be
* supported by some compiler/processor environments. For greater
* portability, use the IntN or UIntN types above.
*/
typedef xdc_Bits8 Bits8;
typedef xdc_Bits16 Bits16;
typedef xdc_Bits32 Bits32;
typedef xdc_Bits64 Bits64;
/* Standard Constants */
/* Declaration Qualifiers */
/*
* ======== xdc__CODESECT ========
* Code-Section Directive
*
* Targets can optionally #define xdc__CODESECT in their specific
* std.h files. This directive is placed in front of all
* "extern" function declarations, and specifies a section-name in
* which to place this function. This approach
* provides more control on combining/organizing groups of
* related functions into a single named sub-section (e.g.,
* "init-code") If this macro is not defined by the target, an
* empty definition is used instead.
*/
/*
* ======== xdc__META ========
* Embed unreferenced string in the current file
*
* Strings emebdded via xdc__META can be placed in a section that is
* _not_ loaded on the target but are, nevertheless, part of the
* executable and available to loaders.
*
* Different targets may define this macro in a way that places these
* strings in an output section that is not loaded (and therefore does
* not takeup space on the target). Unless the target provides a
* definition of xdc__META, the definition below simply defines
* as string constant in the current file.
*/
/*
* @(#) xdc; 1, 1, 1,343; 7-14-2011 17:21:47; /db/ztree/library/trees/xdc/xdc-x16x/src/packages/
*/
//#include <smart/ipj/image/ImageTypes.h>
//#define PIXEL(image, x, y) (image[x + y*ImageTypes_FRAME_WIDTH_MAX])
void AO_findMinMax(Int16 *restrict piImage, Int16 *piMin, Int16 *piMax);
Int32 AO_calcInitialSSD(Int16 *restrict piImage, Int16 black, Int16 white);
/******************************************************************************/
void AO_findMinMax(Int16 *restrict piImage, Int16 *piMin, Int16 *piMax)
{
/* Find min/max of search area in image */
Int16 min = 32767;
Int16 max = -32767;
Int16 x, y;
Int16 temp;
for(y = (10); y < (470-((30)+(30)+(30))) + ((30)+(30)+(30)); y++)
{
for(x = (100); x < (600-((30)+(50)+(30))) + ((30)+(50)+(30)); x++)
{
temp = piImage[x];
if(temp < min)
{
min = temp;
}
}
}
*piMin = min;
*piMax = max;
}
cl6x -c -qq -pdsw225 -mv6740 -eo.o674 -ea.s674 -mi100 -mo --gcc -O2 -fc autoorient_help1.pp
"Autoorient_help1.pp", line 537: warning: function "xdc_iargToPtr" was declared but never referenced
"Autoorient_help1.pp", line 538: warning: function "xdc_uargToPtr" was declared but never referenced
"Autoorient_help1.pp", line 540: warning: function "xdc_iargToFxn" was declared but never referenced
"Autoorient_help1.pp", line 541: warning: function "xdc_uargToFxn" was declared but never referenced
"Autoorient_help1.pp", line 552: warning: function "xdc_floatToArg" was declared but never referenced
"Autoorient_help1.pp", line 560: warning: function "xdc_argToFloat" was declared but never referenced
INTERNAL ERROR: opt6x.exe experienced a segmentation fault while processing function _AO_findMinMax file C:\\DOCUME~1\\xxx\\LOCALS~1\\Temp\\044043
This is a serious problem. Please contact Customer
Support with this message and a copy of the input file
and help us to continue to make the tools more robust.
>> Compilation failure
Using version 7.3.2 of the tools; compiling for the c6748.