Readme for C29 Clang Code Generation Tools 2.1.0.STS

Table of Contents

Introduction

Version 2.1.0.STS of the C29 Clang Compiler Tools, also known as the c29clang compiler, is derived from the open source LLVM/Clang source code base and the LLVM Compiler Infrastructure source base that can be found in GitHub (github.com).

The c29clang compiler can be used to compile and link C/C++ and assembly source files to build static executable application files that can be loaded and run on a C29 processor.

Short-Term Support Release

This is a Short-Term Support (STS) release.

For definitions and explanations of STS, LTS, and the versioning number scheme, please see SDTO Compiler Version Numbers.

Documentation

The C29 Clang Compiler Tools User’s Guide is now available online at the following URL:

TI E2E Community - Where to Get Help

Post compiler related questions to the TI E2E design community forum and select the TI device being used.

The following is the top-level webpage for all of TI’s Code Generation Tools.

If submitting a defect report, please attach a scaled-down test case with command-line options and the compiler version number to allow us to reproduce the issue easily.

Defect Tracking Database

Compiler defect reports can be tracked at the new Development Tools bug database, SIR. SIR is a JIRA-based view into all public tools defects.

A my.ti.com account is required to access this page. To find an issue in SIR, enter your defect id in the top right search box once logged in. Alternatively, from the top red navigation bar, select “Issues” then “Search for Issues”.

New Features Added in the 2.1.0.STS Release

Software Floating Point Support

In some interrupt use-cases, the save/restore of floating-point registers adds unnecessary overhead in the form of code size and load/store cycles. Previous solutions to avoid this overhead have run into issues with the compiler assuming that floating point registers are still available. This is because under default conditions the hardware supports floating point registers and operations, which conflicts with the software that doesn’t want it.

For the 2.1.0.STS release, the repurposed -mfpu=none option can now be used to fully disable floating point registers. Code compiled with -mfpu=none is not compatible with code compiled with -mfpu=f32 or -mfpu=f64, and interlinking such code will cause errors during compilation. Any floating-point operations in code compiled with -mfpu=none is guaranteed to not use floating point registers, but will suffer major performance and code size degradation similar to using 64-bit floating point operations with -mfpu=f64.

The c29clang compiler toolchain now supports the powerful link-time optimization strategy. When ‘-flto’ is passed as an option to a link command, the linker identifies other object files (including those in libraries) that were compiled with ‘-flto’ and generates a single, combined code module. The compiler uses this new knowledge to further optimize the final program. For example, consider two source files:

// file1.c
extern int return_value();
int add_value(int x) { return x + return_value(); }

// file2.c
int return_value() { return 5; }

With c29clang file1.c file2.c -O3, the compiler can’t see the definition of ‘return_value’ in ‘file2.c’ while optimizing ‘file1.c’, leading the generated code for add_value to contain a non-performant CALL sequence.

With c29clang file1.c file2.c -flto -O3, the compiler acts the same as before until the linker executes. The tool will extract representations of code from file1.c and file2.c and generate a new translation unit that looks similar to:

// files.c
extern int return_value();
int add_value(int x) { return x + return_value(); }
int return_value() { return 5; }

This is optimized once more. Now that the compiler can see the definition of return_value, it can replace the call to it in add_value with the literal 5, removing the CALL sequence entirely.

All objects must be built with -flto to be included in optimization strategy. In particular, it’s important that libraries built or imported into your project have been built with -flto. Objects not built with -flto will not be added to the combined module.

Link-time optimization interacts in complex ways with hardware security configurations because it involves the movement of code and data accesses across what may be a secure boundary containing protected calls and returns. This means that the presence of security in a link-time optimized project may degrade performance over that same project with no security.

Two major issues with LTO have been resolved:

    // Attempt to capture all code from main.o
    main.o(.text) > RAM

    // Possible warning emitted by the linker
    warning #10247-D: creating output section ".text" without a SECTONS specification

Performance/Code Size Improvements

Host Support / Dependencies

The following host-specific versions of the 2.1.0.STS c29clang compiler tools are available:

Device Support

The c29clang compiler tools support development of applications that are to be loaded and run on one of the following processor and runtime environment configurations:

Runtime Environment Configuration Options
C29 (default) “-mcpu=c29.c0”
Floating Point 32bit hardware ops, 64bit emulation (default) “-mfpu=f32”
Floating Point 32bit and 64bit hardware ops “-mfpu=f64”
Floating Point 32bit emulation, 64bit emulation “-mfpu=none”

Resolved Defects

ID Summary
CODEGEN-14525 c29clang-tidy terminates unexpectedly with checker c29migration-c28-pragmas enabled
CODEGEN-14522 c29clang-tidy reports “unknown target CPU”
CODEGEN-14222 The function attribute((destructor)) is silently ignored
CODEGEN-14179 Compiler allocates wrong register for asm statement
CODEGEN-13204 Document support for “#pragma GCC diagnostic” and “#pragma clang diagnostic”

Known Defects

The up-to-date known defects in v2.1.0.STS can be found here (dynamically generated):

End of File