This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][NFC] Remove SIMD check lines for non-simd tests
ClosedPublic

Authored by jdoerfert on May 5 2021, 10:38 PM.

Details

Summary

If a test does not contain an " simd" but -fopenmp-simd RUN lines we can
just check that we do not create kmpc|tgt calls.

Diff Detail

Event Timeline

jdoerfert created this revision.May 5 2021, 10:38 PM
jdoerfert requested review of this revision.May 5 2021, 10:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2021, 10:38 PM
This revision is now accepted and ready to land.May 6 2021, 4:28 AM
jdoerfert updated this revision to Diff 346579.May 19 2021, 3:00 PM

Make the script remove leftover CHECK: lines that would now trigger given
the absence of a specific check prefix for the -fopenmp-simd invocations.

jdoerfert updated this revision to Diff 346604.May 19 2021, 6:04 PM

Accidentally deleted too many check lines this time ...

I can't see a change to a script in this diff. Should there be one? Looks like the test change was done programmatically

I can't see a change to a script in this diff. Should there be one? Looks like the test change was done programmatically

It was, but I did not expect to need the script in the future.

If you really want to see how bad my python skills are, here you go ;)

import os,re

path = "clang/test/OpenMP/"
for f in os.listdir(path):
    if not os.path.isfile(path+f):
        continue
    fd = open(path + f, "r")
    content = fd.read()
    fd.close()

    if "_cc_test_check" not in content:
        continue
    if " simd" in content or " SIMD" in content:
        continue
    if "-fopenmp-simd" not in content:
        continue

    changed = False
    lines = content.splitlines()
    newlines = []
    matches = ['// CHECK:', '// CHECK-', '//CHECK:', '//CHECK-']
    empty = 0
    for i in range(len(lines)):
        line = lines[i]
        match = False
        for m in matches:
            if m in line:
                match = True
                break
        if match:
            continue
        if line == "//":
            empty += 1
            if empty > 2:
                continue
        else:
            empty = 0
        if "-fopenmp-simd" not in line:
            newlines.append(line)
            continue
        if "FileCheck" not in line:
            newlines.append(line)
            continue
        m = re.search(r"=((SIMD|CHECK)[^\s]*)", line)
        if not m:
            newlines.append(line)
            continue
        print(m.group(1))
        matches.append(m.group(1))

        idx = line.index("FileCheck")
        line = line[:idx]
        line += 'FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"'
        newlines.append(line)
        changed = True

    if changed:
        fd = open(path + f, "w")
        fd.write('\n'.join(newlines))
        fd.close()