Page MenuHomePhabricator

Add ConstantDataVector::getRaw() to create a constant data vector from raw data.
ClosedPublic

Authored by nickwasmer on Mar 9 2021, 3:49 PM.

Details

Summary

This parallels ConstantDataArray::getRaw() and can be used with ConstantDataSequential::getRawDataValues() in the base class for both types.

Update BuildConstantData{Array,Vector} test to use the getRaw API. Also removes its unused Module and update some variable names.

In passing, update some comments to include the support for half and bfloat. Update tests to include testing for bfloat.

Diff Detail

Event Timeline

nickwasmer requested review of this revision.Mar 9 2021, 3:49 PM
nickwasmer created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2021, 3:49 PM

Apply formatting changes raised by "llvm-premerge-checks".

Remove one blank line pointed out by clang-format.

Phab mangled my patch from:

index 96d3672647e8..8d0e06a62d36 100644
--- llvm/unittests/IR/ConstantsTest.cpp
+++ llvm/unittests/IR/ConstantsTest.cpp
@@ -1,717 +1,725 @@

to

diff --git a/llvm/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp
--- a/llvm/unittests/IR/ConstantsTest.cpp
+++ b/unittests/IR/ConstantsTest.cpp
@@ -23,11 +23,11 @@

breaking the build.

Try regenerating the patch without the --no-prefix flag.

Fix clang-tidy-diff complaints from the builder.

Can you push all of the formatting changes before adding the new API and its tests? No Phab pre-commit review needed for no-functional-change cosmetic diffs.

Rebase on top of main after landing the formatting changes separately.

spatel accepted this revision.Mar 16 2021, 8:43 AM

LGTM - I'm not sure about the intended usage for these APIs, but this looks like a straightforward extension of the existing functionality. See inline for a couple of minor points.

llvm/include/llvm/IR/Constants.h
561–564

bloat -> bfloat

706–707

Does it make sense to assert that the type is one of the expected values inside here?

This revision is now accepted and ready to land.Mar 16 2021, 8:43 AM
nickwasmer marked an inline comment as done.Mar 16 2021, 11:56 AM

I'm not sure about the intended usage for these APIs, but this looks like a straightforward extension of the existing functionality.

It's broken out of https://github.com/wasmerio/llvm-project/compare/main...wasmerio:feature/parallel-link which is a work in progress (only known issue is that Metadata isn't handled yet). I'm using the API to clone the data of the constant across to a different LLVMContext.

llvm/include/llvm/IR/Constants.h
706–707

Yes, I don't see why not. The rule applies to the base class which has a static isElementTypeCompatible method we could use. Let me land this first and then I'll try the assert and make sure it works and we can do that in a small separate review.

This revision was landed with ongoing or failed builds.Mar 16 2021, 11:58 AM
This revision was automatically updated to reflect the committed changes.
nickwasmer added inline comments.Mar 16 2021, 12:00 PM
llvm/include/llvm/IR/Constants.h
706–707

The assert is there after all, it's in ConstantDataSequential::getImpl.