[llvm-dev] stack dump at -early-cse-memssa twice

HwJ via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 23 03:11:06 PDT 2018


Hello,

while invoking opt with all possible optimization pairs I stumbled over
a stack dump when doing -early-cse-memssa twice:

    $ clang -Xclang -disable-O0-optnone -S -o fannkuch7.ll -emit-llvm fannkuch7.c

	$ opt -S -o fannkuch7.ll -early-cse-memssa -early-cse-memssa fannkuch7.ll

Questions:
Is it illegal to call -early-cse-memssa twice?
Are there any other incompatible optimization orders?

Best,
HwJ

---

$ clang --version

> clang version 6.0.0 (tags/RELEASE_600/final)
> Target: x86_64-apple-darwin16.5.0
> Thread model: posix
> InstalledDir: /usr/local/bin

Output:

> 0  opt                      0x000000010d8980e7
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
> 1  opt                      0x000000010d8975ea
> llvm::sys::RunSignalHandlers() + 83
> 2  opt                      0x000000010d89850e
> SignalHandler(int) + 239
> 3  libsystem_platform.dylib 0x00007fff90902b3a _sigtramp + 26
> 4  libsystem_platform.dylib 0x0000000000000001 _sigtramp +
> 1869599969
> 5  opt                      0x000000010d537ec0
> llvm::PMDataManager::add(llvm::Pass*, bool) + 438
> 6  opt                      0x000000010d53a044
> llvm::FunctionPass::assignPassManager(llvm::PMStack&,
> llvm::PassManagerType) + 344
> 7  opt                      0x000000010d536919
> llvm::PMTopLevelManager::schedulePass(llvm::Pass*) + 1243
> 8  opt                      0x000000010c949058 main + 6509
> 9  libdyld.dylib            0x00007fff906f3235 start + 1
> 10 libdyld.dylib            0x0000000000000007 start +
> 1871760851
> Stack dump:
> 0.  Program arguments: opt -S -o fannkuch7.ll
> -early-cse-memssa -early-cse-memssa fannkuch7.ll
-------------- next part --------------
/* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * converted to C by Joseph Piché
 * from Java version by Oleg Mazurov and Isaac Gouy
 *
 */

// n auf 7 festgenagelt
// printf gelöscht
// Ternäroperator umgeschrieben
// %2 ~> &1
// inline gelöscht

int max(int a, int b)
{
    // return a > b ? a : b;
	if (a > b) {
		return a;
	}
	return b;
}

int fannkuch7()
{
    int perm[7];
    int perm1[7];
    int count[7];
    int maxFlipsCount = 0;
    int permCount = 0;
    int checksum = 0;

    int i;

    for (i=0; i<7; i+=1)
        perm1[i] = i;
    int r = 7;

    while (1) {
        while (r != 1) {
            count[r-1] = r;
            r -= 1;
        }

        for (i=0; i<7; i+=1)
            perm[i] = perm1[i];
        int flipsCount = 0;
        int k;

        while ( !((k = perm[0]) == 0) ) {
            int k2 = (k+1) >> 1;
            for (i=0; i<k2; i++) {
                int temp = perm[i]; perm[i] = perm[k-i]; perm[k-i] = temp;
            }
            flipsCount += 1;
        }

        maxFlipsCount = max(maxFlipsCount, flipsCount);
        //checksum += permCount % 2 == 0 ? flipsCount : -flipsCount;
		if ((permCount & 1) == 0) {
			checksum += flipsCount;
		} else {
			checksum -= flipsCount;
		}

        /* Use incremental change to generate another permutation */
        while (1) {
            if (r == 7) {
                return maxFlipsCount;
            }

            int perm0 = perm1[0];
            i = 0;
            while (i < r) {
                int j = i + 1;
                perm1[i] = perm1[j];
                i = j;
            }
            perm1[r] = perm0;
            count[r] = count[r] - 1;
            if (count[r] > 0) break;
            r++;
        }
        permCount++;
    }
	return 0; // nie erreicht
}


More information about the llvm-dev mailing list