Closed Chazzzzzzz closed 5 years ago
Hi,
no, you use the tool correctly. Do you have (at least the relevant) part of the code that triggers this error? In general, I have not implemented the full support for vector instructions, but I think this should be quite easy to do.
Hi,
I am trying to get the dependency graph of libtiff: short_tag.
The source code is here: https://github.com/vadz/libtiff
And I am using the commit version of : b2ce5d8 (git reset --hard b2ce5d8) and compile the short_tag program in the test folder.
I upload a docker environment that I use (including bc file, source file and dg): docker push dockerchaz/dg-testcase:latest
The bc file is : /home/libtiff-bug/libtiff/test/short_tag_new.bc. The source file is /home/libtiff-bug/libtiff/test/short_tag_new.c .
Here is the code of short_tag_new.c if you only want this.
#include "tif_config.h"
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "tiffio.h"
#include "tifftest.h"
static const char filename[] = "short_test.tiff";
#define SPP 3
const uint16 width = 1;
const uint16 length = 1;
const uint16 bps = 8;
const uint16 photometric = PHOTOMETRIC_RGB;
const uint16 rows_per_strip = 1;
const uint16 planarconfig = PLANARCONFIG_CONTIG;
static const struct {
const ttag_t tag;
const uint16 value;
} short_single_tags[] = {
{ TIFFTAG_COMPRESSION, COMPRESSION_NONE },
{ TIFFTAG_FILLORDER, FILLORDER_MSB2LSB },
{ TIFFTAG_ORIENTATION, ORIENTATION_BOTRIGHT },
{ TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH },
{ TIFFTAG_MINSAMPLEVALUE, 23 },
{ TIFFTAG_MAXSAMPLEVALUE, 241 },
{ TIFFTAG_INKSET, INKSET_MULTIINK },
{ TIFFTAG_NUMBEROFINKS, SPP },
{ TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT }
};
#define NSINGLETAGS (sizeof(short_single_tags) / sizeof(short_single_tags[0]))
static const struct {
const ttag_t tag;
const uint16 values[2];
} short_paired_tags[] = {
{ TIFFTAG_PAGENUMBER, {1, 1} },
{ TIFFTAG_HALFTONEHINTS, {0, 255} },
{ TIFFTAG_DOTRANGE, {8, 16} },
{ TIFFTAG_YCBCRSUBSAMPLING, {2, 1} }
};
#define NPAIREDTAGS (sizeof(short_paired_tags) / sizeof(short_paired_tags[0]))
int CheckShortField(TIFF *tif, const ttag_t field, const uint16 value)
{
uint16 tmp = 123;
if (!TIFFGetField(tif, field, &tmp)) {
fprintf (stderr, "Problem fetching tag %lu.\n",
(unsigned long) field);
return -1;
}
if (tmp != value) {
fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n",
(unsigned long) field);
return -1;
}
return 0;
}
int
CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values)
{
uint16 tmp[2] = { 123, 456 };
if (!TIFFGetField(tif, field, tmp, tmp + 1)) {
fprintf (stderr, "Problem fetching tag %lu.\n",
(unsigned long) field);
return -1;
}
if (tmp[0] != values[0] || tmp[1] != values[1]) {
fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n",
(unsigned long) field);
return -1;
}
return 0;
}
int
CheckLongField(TIFF *tif, const ttag_t field, const uint32 value)
{
uint32 tmp = 123;
if (!TIFFGetField(tif, field, &tmp)) {
fprintf (stderr, "Problem fetching tag %lu.\n",
(unsigned long) field);
return -1;
}
if (tmp != value) {
fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n",
(unsigned long) field);
return -1;
}
return 0;
}
int
main()
{
TIFF *tif;
size_t i;
unsigned char buf[SPP] = { 0, 127, 255 };
tif = TIFFOpen(filename, "w");
if (!tif) {
fprintf (stderr, "Can't create test TIFF file %s.\n", filename);
return 1;
}
if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) {
fprintf (stderr, "Can't set ImageWidth tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) {
fprintf (stderr, "Can't set ImageLength tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) {
fprintf (stderr, "Can't set BitsPerSample tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) {
fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) {
fprintf (stderr, "Can't set SamplesPerPixel tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) {
fprintf (stderr, "Can't set PlanarConfiguration tag.\n");
goto failure;
}
if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) {
fprintf (stderr, "Can't set PhotometricInterpretation tag.\n");
goto failure;
}
for (i = 0; i < NSINGLETAGS; i++) {
if (!TIFFSetField(tif, short_single_tags[i].tag,
short_single_tags[i].value)) {
fprintf(stderr, "Can't set tag %lu.\n",
(unsigned long)short_single_tags[i].tag);
goto failure;
}
}
for (i = 0; i < NPAIREDTAGS; i++) {
if (!TIFFSetField(tif, short_paired_tags[i].tag,
short_paired_tags[i].values[0],
short_paired_tags[i].values[1])) {
fprintf(stderr, "Can't set tag %lu.\n",
(unsigned long)short_paired_tags[i].tag);
goto failure;
}
}
if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
fprintf (stderr, "Can't write image data.\n");
goto failure;
}
TIFFClose(tif);
tif = TIFFOpen(filename, "r");
if (!tif) {
fprintf (stderr, "Can't open test TIFF file %s.\n", filename);
return 1;
}
if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0)
goto failure;
if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0)
goto failure;
if (CheckShortField(tif, TIFFTAG_BITSPERSAMPLE, bps) < 0)
goto failure;
if (CheckShortField(tif, TIFFTAG_PHOTOMETRIC, photometric) < 0)
goto failure;
if (CheckShortField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP) < 0)
goto failure;
if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0)
goto failure;
if (CheckShortField(tif, TIFFTAG_PLANARCONFIG, planarconfig) < 0)
goto failure;
for (i = 0; i < NSINGLETAGS; i++) {
if (CheckShortField(tif, short_single_tags[i].tag,
short_single_tags[i].value) < 0)
goto failure;
}
for (i = 0; i < NPAIREDTAGS; i++) {
if (CheckShortPairedField(tif, short_paired_tags[i].tag,
short_paired_tags[i].values) < 0)
goto failure;
}
TIFFClose(tif);
unlink(filename);
return 0;
failure:
TIFFClose(tif);
return 1;
}
I've ran into the same issue, in my case the vector instructions were added by the clang llvm optimizations. Then my workaround was to disable them with the -fno-vectorize flag. Maybe that helps you for the moment.
Hi, Great thanks to ur effort in this tool first !!! When I try to use this tool to get the dependency graph of a program. I encounter the following error:
root@f1c41799566b:/home# llvm-dg-dump short_tag_new.bc WARNING: Non-0 memset: tail call void @llvm.memset.p0i8.i64(i8* align 1 %0, i8 %4, i64 %5, i1 false), !dbg !6769 %763 = insertelement <8 x i16> undef, i16 %762, i32 0 llvm-dg-dump: /home/dg/lib/llvm/analysis/PointsTo/PointerSubgraph.cpp:488: dg::analysis::pta::PSNodesSeq dg::analysis::pta::LLVMPointerSubgraphBuilder::buildInstruction(const llvm::Instruction&): Assertion 0 && "Unhandled instruction"' failed. Aborted (core dumped) root@f1c41799566b:/home# llvm-dg-dump short_tag_new.bc > file.dot WARNING: Non-0 memset: tail call void @llvm.memset.p0i8.i64(i8* align 1 %0, i8 %4, i64 %5, i1 false), !dbg !6769 %763 = insertelement <8 x i16> undef, i16 %762, i32 0 llvm-dg-dump: /home/dg/lib/llvm/analysis/PointsTo/PointerSubgraph.cpp:488: dg::analysis::pta::PSNodesSeq dg::analysis::pta::LLVMPointerSubgraphBuilder::buildInstruction(const llvm::Instruction&): Assertion 0 && "Unhandled instruction"' failed. Aborted (core dumped)
It seems that "insertelement" instruction is currently not suported by this tool.
Do u have any plan to support it in the near future? Or do I use this tool in a wrong way??
Thanks