This is an archive of the discontinued LLVM Phabricator instance.

[safestack] Require TargetMachine to be provided.
ClosedPublic

Authored by mlemay-intel on Sep 24 2016, 4:50 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

mlemay-intel retitled this revision from to [safestack] Require TargetMachine to be provided..
mlemay-intel updated this object.
mlemay-intel added reviewers: pcc, eugenis.
mlemay-intel added a subscriber: llvm-commits.
eugenis edited edge metadata.Sep 26 2016, 11:55 AM

This crashes opt -safe-stack when the input file does not specify a target triple. This is probably fine... Is it?

pcc edited edge metadata.Sep 26 2016, 12:07 PM

We probably want to call report_fatal_error if we were unable to get a TargetMachine.

mlemay-intel edited edge metadata.

Convert assert to report_fatal_error.

pcc accepted this revision.Sep 26 2016, 2:45 PM
pcc edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 26 2016, 2:45 PM
This revision was automatically updated to reflect the committed changes.

The hexagon-build-02 buildbot detected failures caused by this patch: http://lab.llvm.org:8011/builders/llvm-hexagon-elf/builds/34095 The "Target machine is required" error is being reported. I was able to reproduce those failures by building a version of LLVM that only targets Hexagon. I'm surprised by these failures, since I would expect such a toolchain to simply report that the test is unsupported given that X86 triples are specified on the opt command lines. I don't yet know of a good way to revise this patch to resolve those failures while still avoiding duplicating code in D19852.

pcc added a comment.Oct 5 2016, 2:41 PM

You could add REQUIRES: x86-registered-target to each of the failing tests

In D24896#562745, @pcc wrote:

You could add REQUIRES: x86-registered-target to each of the failing tests

I see that none of the tests in test/Transforms/SafeStack/ currently specify any non-X86 target. The only tests that do are in arch-specific subdirectories. So, adding the REQUIRES: x86-registered-target directive could work. However, I wonder whether it will be necessary in the future to add non-X86 targets to the tests in the base directory.

pcc added a comment.Oct 6 2016, 10:46 AM

Ah, I didn't see the arch specific directories. In that case I think the simplest thing to do would be to move the existing tests to the X86 directory. If we ever need to run one of those tests on multiple architectures we can always move it back with a REQUIRES directive.

It looks like the explicit triples are being used in the tests in the non-arch-specific directory simply to force the tests to be run for both x86-64 and i386 targets. This is great for x86, but it means that these tests aren't run at all against other targets, even when another target is the default for the build. That seems bad.

I would be inclined to remove the explicit triple from these tests and look for another way to exercise the 32-bit x86 targets. A quick and dirty way to do this would be to duplicate the tests as they are now in the X86 directory and leave a version without an explicit triple in the non-arch directory. That's not a good long-term solution but I'm not sure what other options are available. There must be other tests that have this same dilemma though.

Is it possible that a much smaller set of tests could verify whatever i386-specific behavior needs to be tested?

pcc added a comment.Oct 6 2016, 2:55 PM

It looks like the explicit triples are being used in the tests in the non-arch-specific directory simply to force the tests to be run for both x86-64 and i386 targets. This is great for x86, but it means that these tests aren't run at all against other targets, even when another target is the default for the build. That seems bad.

I would be inclined to remove the explicit triple from these tests and look for another way to exercise the 32-bit x86 targets. A quick and dirty way to do this would be to duplicate the tests as they are now in the X86 directory and leave a version without an explicit triple in the non-arch directory. That's not a good long-term solution but I'm not sure what other options are available. There must be other tests that have this same dilemma though.

Ultimately we do want these tests to run against as many targets as possible, but I think the best way to do that is with a test with multiple RUN lines with different triples, rather than depending on the host triple. The latter seems like a good way to have missing test coverage depending on which platform you happen to be running on.

Moving the existing tests to X86 is a good first step because we don't currently have any tests that target more than one architecture. As we accumulate such tests (either by changing the tests in X86 or by adding new tests) we can move them up one directory.

Is it possible that a much smaller set of tests could verify whatever i386-specific behavior needs to be tested?

That may certainly be true, but it's orthogonal to fixing our present build issue.

The problem with adding more run lines is that if I understand this failure correctly, the test would fail if any of the run targets was missing from the build configuration. Long term, I think it would be nice if LIT had a way to selectively disable individual run lines based on the build configuration.

pcc added a comment.Oct 6 2016, 4:11 PM

The problem with adding more run lines is that if I understand this failure correctly, the test would fail if any of the run targets was missing from the build configuration.

Not necessarily, you could have something like REQUIRES: foo-registered-target, bar-registered-target (but would agree this is suboptimal)

Long term, I think it would be nice if LIT had a way to selectively disable individual run lines based on the build configuration.

Agree