github.com/llir/llvm@v0.3.6/asm/asm_test.go (about)

     1  package asm
     2  
     3  import (
     4  	"io/ioutil"
     5  	"log"
     6  	"path/filepath"
     7  	"testing"
     8  
     9  	"github.com/google/go-cmp/cmp"
    10  	"github.com/llir/llvm/internal/osutil"
    11  )
    12  
    13  func TestParseFile(t *testing.T) {
    14  	golden := []struct {
    15  		path string
    16  	}{
    17  		{path: "testdata/hexfloat.ll"},
    18  		{path: "testdata/hexint.ll"},
    19  		{path: "testdata/inst_aggregate.ll"},
    20  		{path: "testdata/inst_binary.ll"},
    21  		{path: "testdata/inst_bitwise.ll"},
    22  		{path: "testdata/inst_conversion.ll"},
    23  		{path: "testdata/inst_memory.ll"},
    24  		{path: "testdata/inst_other.ll"},
    25  		{path: "testdata/inst_vector.ll"},
    26  		{path: "testdata/terminator.ll"},
    27  
    28  		// DIExpression used in named metdata definition.
    29  		{path: "testdata/diexpression.ll"},
    30  
    31  		// Multiple named metadata definitions with the same metadata name should
    32  		// be merged into one.
    33  		{path: "testdata/multiple_named_metadata_defs.ll"},
    34  
    35  		// frem constant expression.
    36  		{path: "testdata/expr_frem.ll"},
    37  
    38  		// parameter attributes.
    39  		{path: "testdata/param_attrs.ll"},
    40  
    41  		// function alignment.
    42  		{path: "testdata/func_align.ll"},
    43  
    44  		// global alignment.
    45  		{path: "testdata/global_align.ll"},
    46  
    47  		// LLVM IR compatibility.
    48  		{path: "../testdata/llvm/test/Bitcode/compatibility.ll"},
    49  
    50  		// Specialized metadata.
    51  		{path: "../testdata/llvm/test/DebugInfo/Generic/DICommonBlock.ll"},
    52  
    53  		// Basic block with same name as specialized metadata field (issue #49).
    54  		{path: "../testdata/llvm/test/Analysis/ScalarEvolution/2008-02-15-UMax.ll"},
    55  
    56  		// Specialized metadata.
    57  		{path: "../testdata/llvm/test/DebugInfo/Generic/debug_value_list.ll"},
    58  
    59  		// Floating-point test cases (issue #31).
    60  		{path: "../testdata/llvm/test/Analysis/CostModel/AMDGPU/fdiv.ll"},
    61  
    62  		// float infinity and not-a-number.
    63  		{path: "../testdata/llvm/test/Assembler/2002-04-07-InfConstant.ll"},
    64  		{path: "../testdata/llvm/test/Analysis/BasicAA/pr18573.ll"},
    65  
    66  		// Distinguish named from unnamed locals (issue #39).
    67  		{path: "../testdata/llvm/test/Analysis/DominanceFrontier/new_pm_test.ll"},
    68  
    69  		// Empty array constant.
    70  		{path: "../testdata/llvm/test/Assembler/aggregate-constant-values.ll"},
    71  
    72  		// gep with vector indices.
    73  		{path: "../testdata/llvm/test/Assembler/ConstantExprFold.ll"},
    74  		{path: "../testdata/llvm/test/Assembler/getelementptr.ll"},
    75  
    76  		// Large values in metadata.
    77  		{path: "../testdata/llvm/test/Assembler/ditype-large-values.ll"},
    78  
    79  		// fadd, fmul and fcmp constant expressions.
    80  		{path: "../testdata/llvm/test/DebugInfo/ARM/selectiondag-deadcode.ll"},
    81  
    82  		// fsub constant expressions.
    83  		{path: "../testdata/llvm/test/Transforms/InstCombine/fma.ll"},
    84  
    85  		// Constant expressions.
    86  		{path: "../testdata/llvm/test/Transforms/ConstProp/constant-expr.ll"},
    87  
    88  		// Vector constant expressions.
    89  		{path: "../testdata/llvm/test/Transforms/InstCombine/vec_demanded_elts.ll"},
    90  		{path: "../testdata/llvm/test/Transforms/InstCombine/vector_insertelt_shuffle.ll"},
    91  
    92  		// Use of address space in function declaration and dereferenable
    93  		// parameter attribute.
    94  		{path: "../testdata/llvm/test/Transforms/InstSimplify/compare.ll"},
    95  
    96  		// Basic block labels.
    97  		{path: "../testdata/llvm/test/Assembler/block-labels.ll"},
    98  
    99  		// callbr with void callee should not use up local ID in ir.Func.AssignIDs.
   100  		{path: "../testdata/llvm/test/Transforms/LoopUnswitch/callbr.ll"},
   101  
   102  		// Calling conventions.
   103  		{path: "../testdata/llvm/test/Bitcode/calling-conventions.3.2.ll"},
   104  		{path: "../testdata/llvm/test/CodeGen/X86/tailccfp.ll"},
   105  
   106  		// Parameter attributes.
   107  		{path: "../testdata/llvm/test/Bitcode/attributes.ll"},
   108  
   109  		// Parameter attributes (nofree).
   110  		{path: "../testdata/llvm/test/Transforms/Attributor/nonnull.ll"},
   111  
   112  		// LLVM test/Features.
   113  		{path: "../testdata/llvm/test/Feature/OperandBundles/adce.ll"},
   114  		{path: "../testdata/llvm/test/Feature/OperandBundles/basic-aa-argmemonly.ll"},
   115  		{path: "../testdata/llvm/test/Feature/OperandBundles/dse.ll"},
   116  		{path: "../testdata/llvm/test/Feature/OperandBundles/early-cse.ll"},
   117  		{path: "../testdata/llvm/test/Feature/OperandBundles/function-attrs.ll"},
   118  		{path: "../testdata/llvm/test/Feature/OperandBundles/inliner-conservative.ll"},
   119  		{path: "../testdata/llvm/test/Feature/OperandBundles/merge-func.ll"},
   120  		{path: "../testdata/llvm/test/Feature/OperandBundles/pr26510.ll"},
   121  		{path: "../testdata/llvm/test/Feature/OperandBundles/special-state.ll"},
   122  		{path: "../testdata/llvm/test/Feature/alias2.ll"},
   123  		{path: "../testdata/llvm/test/Feature/aliases.ll"},
   124  		{path: "../testdata/llvm/test/Feature/alignment.ll"},
   125  		{path: "../testdata/llvm/test/Feature/attributes.ll"},
   126  		{path: "../testdata/llvm/test/Feature/basictest.ll"},
   127  		{path: "../testdata/llvm/test/Feature/callingconventions.ll"},
   128  		{path: "../testdata/llvm/test/Feature/calltest.ll"},
   129  		{path: "../testdata/llvm/test/Feature/casttest.ll"},
   130  		{path: "../testdata/llvm/test/Feature/cfgstructures.ll"},
   131  		{path: "../testdata/llvm/test/Feature/cold.ll"},
   132  		{path: "../testdata/llvm/test/Feature/comdat.ll"},
   133  		{path: "../testdata/llvm/test/Feature/constexpr.ll"},
   134  		{path: "../testdata/llvm/test/Feature/constpointer.ll"},
   135  		{path: "../testdata/llvm/test/Feature/const_pv.ll"},
   136  		{path: "../testdata/llvm/test/Feature/elf-linker-options.ll"},
   137  		{path: "../testdata/llvm/test/Feature/escaped_label.ll"},
   138  		{path: "../testdata/llvm/test/Feature/exception.ll"},
   139  		{path: "../testdata/llvm/test/Feature/float.ll"},
   140  		{path: "../testdata/llvm/test/Feature/fold-fpcast.ll"},
   141  		{path: "../testdata/llvm/test/Feature/forwardreftest.ll"},
   142  		{path: "../testdata/llvm/test/Feature/fp-intrinsics.ll"},
   143  		{path: "../testdata/llvm/test/Feature/global_pv.ll"},
   144  		{path: "../testdata/llvm/test/Feature/global_section.ll"},
   145  		{path: "../testdata/llvm/test/Feature/globalvars.ll"},
   146  		{path: "../testdata/llvm/test/Feature/indirectcall2.ll"},
   147  		{path: "../testdata/llvm/test/Feature/indirectcall.ll"},
   148  		{path: "../testdata/llvm/test/Feature/inlineasm.ll"},
   149  		{path: "../testdata/llvm/test/Feature/instructions.ll"},
   150  		{path: "../testdata/llvm/test/Feature/intrinsic-noduplicate.ll"},
   151  		{path: "../testdata/llvm/test/Feature/intrinsics.ll"},
   152  		{path: "../testdata/llvm/test/Feature/load_module.ll"},
   153  		{path: "../testdata/llvm/test/Feature/md_on_instruction.ll"},
   154  		{path: "../testdata/llvm/test/Feature/memorymarkers.ll"},
   155  		{path: "../testdata/llvm/test/Feature/metadata.ll"},
   156  		{path: "../testdata/llvm/test/Feature/minsize_attr.ll"},
   157  		{path: "../testdata/llvm/test/Feature/NamedMDNode2.ll"},
   158  		{path: "../testdata/llvm/test/Feature/NamedMDNode.ll"},
   159  		{path: "../testdata/llvm/test/Feature/newcasts.ll"},
   160  		{path: "../testdata/llvm/test/Feature/optnone.ll"},
   161  		{path: "../testdata/llvm/test/Feature/optnone-llc.ll"},
   162  		{path: "../testdata/llvm/test/Feature/optnone-opt.ll"},
   163  		{path: "../testdata/llvm/test/Feature/packed.ll"},
   164  		{path: "../testdata/llvm/test/Feature/packed_struct.ll"},
   165  		{path: "../testdata/llvm/test/Feature/paramattrs.ll"},
   166  		{path: "../testdata/llvm/test/Feature/ppcld.ll"},
   167  		{path: "../testdata/llvm/test/Feature/prefixdata.ll"},
   168  		{path: "../testdata/llvm/test/Feature/prologuedata.ll"},
   169  		{path: "../testdata/llvm/test/Feature/properties.ll"},
   170  		{path: "../testdata/llvm/test/Feature/prototype.ll"},
   171  		{path: "../testdata/llvm/test/Feature/recursivetype.ll"},
   172  		{path: "../testdata/llvm/test/Feature/seh-nounwind.ll"},
   173  		{path: "../testdata/llvm/test/Feature/simplecalltest.ll"},
   174  		{path: "../testdata/llvm/test/Feature/smallest.ll"},
   175  		{path: "../testdata/llvm/test/Feature/small.ll"},
   176  		{path: "../testdata/llvm/test/Feature/sparcld.ll"},
   177  		{path: "../testdata/llvm/test/Feature/strip_names.ll"},
   178  		{path: "../testdata/llvm/test/Feature/terminators.ll"},
   179  		{path: "../testdata/llvm/test/Feature/testalloca.ll"},
   180  		{path: "../testdata/llvm/test/Feature/testconstants.ll"},
   181  		{path: "../testdata/llvm/test/Feature/testlogical.ll"},
   182  		//{path: "../testdata/llvm/test/Feature/testtype.ll"}, // TODO: fix nil pointer dereference
   183  		{path: "../testdata/llvm/test/Feature/testvarargs.ll"},
   184  		{path: "../testdata/llvm/test/Feature/undefined.ll"},
   185  		{path: "../testdata/llvm/test/Feature/unreachable.ll"},
   186  		{path: "../testdata/llvm/test/Feature/varargs.ll"},
   187  		{path: "../testdata/llvm/test/Feature/varargs_new.ll"},
   188  		{path: "../testdata/llvm/test/Feature/vector-cast-constant-exprs.ll"},
   189  		{path: "../testdata/llvm/test/Feature/weak_constant.ll"},
   190  		{path: "../testdata/llvm/test/Feature/weirdnames.ll"},
   191  		{path: "../testdata/llvm/test/Feature/x86ld.ll"},
   192  
   193  		// LLVM test/Assembler.
   194  		{path: "../testdata/llvm/test/Assembler/2002-03-08-NameCollision.ll"},
   195  		{path: "../testdata/llvm/test/Assembler/2002-03-08-NameCollision2.ll"},
   196  		{path: "../testdata/llvm/test/Assembler/2002-04-07-HexFloatConstants.ll"},
   197  		{path: "../testdata/llvm/test/Assembler/2002-04-29-NameBinding.ll"},
   198  		{path: "../testdata/llvm/test/Assembler/2002-05-02-InvalidForwardRef.ll"},
   199  		{path: "../testdata/llvm/test/Assembler/2002-07-14-OpaqueType.ll"},
   200  		{path: "../testdata/llvm/test/Assembler/2002-07-25-QuoteInString.ll"},
   201  		{path: "../testdata/llvm/test/Assembler/2002-07-25-ReturnPtrFunction.ll"},
   202  		{path: "../testdata/llvm/test/Assembler/2002-07-31-SlashInString.ll"},
   203  		{path: "../testdata/llvm/test/Assembler/2002-08-15-CastAmbiguity.ll"},
   204  		{path: "../testdata/llvm/test/Assembler/2002-08-15-ConstantExprProblem.ll"},
   205  		{path: "../testdata/llvm/test/Assembler/2002-08-15-UnresolvedGlobalReference.ll"},
   206  		{path: "../testdata/llvm/test/Assembler/2002-08-16-ConstExprInlined.ll"},
   207  		{path: "../testdata/llvm/test/Assembler/2002-08-19-BytecodeReader.ll"},
   208  		{path: "../testdata/llvm/test/Assembler/2002-08-22-DominanceProblem.ll"},
   209  		{path: "../testdata/llvm/test/Assembler/2002-10-08-LargeArrayPerformance.ll"},
   210  		{path: "../testdata/llvm/test/Assembler/2002-10-13-ConstantEncodingProblem.ll"},
   211  		{path: "../testdata/llvm/test/Assembler/2002-12-15-GlobalResolve.ll"},
   212  		{path: "../testdata/llvm/test/Assembler/2003-01-30-UnsignedString.ll"},
   213  		{path: "../testdata/llvm/test/Assembler/2003-04-25-UnresolvedGlobalReference.ll"},
   214  		{path: "../testdata/llvm/test/Assembler/2003-05-03-BytecodeReaderProblem.ll"},
   215  		{path: "../testdata/llvm/test/Assembler/2003-05-12-MinIntProblem.ll"},
   216  		{path: "../testdata/llvm/test/Assembler/2003-05-15-AssemblerProblem.ll"},
   217  		{path: "../testdata/llvm/test/Assembler/2003-05-15-SwitchBug.ll"},
   218  		{path: "../testdata/llvm/test/Assembler/2003-05-21-ConstantShiftExpr.ll"},
   219  		{path: "../testdata/llvm/test/Assembler/2003-05-21-EmptyStructTest.ll"},
   220  		{path: "../testdata/llvm/test/Assembler/2003-08-20-ConstantExprGEP-Fold.ll"},
   221  		{path: "../testdata/llvm/test/Assembler/2003-08-21-ConstantExprCast-Fold.ll"},
   222  		{path: "../testdata/llvm/test/Assembler/2003-11-05-ConstantExprShift.ll"},
   223  		{path: "../testdata/llvm/test/Assembler/2003-11-12-ConstantExprCast.ll"},
   224  		{path: "../testdata/llvm/test/Assembler/2004-01-11-getelementptrfolding.ll"},
   225  		{path: "../testdata/llvm/test/Assembler/2004-01-20-MaxLongLong.ll"},
   226  		{path: "../testdata/llvm/test/Assembler/2004-02-01-NegativeZero.ll"},
   227  		{path: "../testdata/llvm/test/Assembler/2004-02-27-SelfUseAssertError.ll"},
   228  		{path: "../testdata/llvm/test/Assembler/2004-03-07-FunctionAddressAlignment.ll"},
   229  		{path: "../testdata/llvm/test/Assembler/2004-04-04-GetElementPtrIndexTypes.ll"},
   230  		{path: "../testdata/llvm/test/Assembler/2004-06-07-VerifierBug.ll"},
   231  		{path: "../testdata/llvm/test/Assembler/2004-10-22-BCWriterUndefBug.ll"},
   232  		{path: "../testdata/llvm/test/Assembler/2005-01-03-FPConstantDisassembly.ll"},
   233  		{path: "../testdata/llvm/test/Assembler/2005-01-31-CallingAggregateFunction.ll"},
   234  		{path: "../testdata/llvm/test/Assembler/2005-05-05-OpaqueUndefValues.ll"},
   235  		{path: "../testdata/llvm/test/Assembler/2005-12-21-ZeroInitVector.ll"},
   236  		{path: "../testdata/llvm/test/Assembler/2006-12-09-Cast-To-Bool.ll"},
   237  		{path: "../testdata/llvm/test/Assembler/2007-01-05-Cmp-ConstExpr.ll"},
   238  		{path: "../testdata/llvm/test/Assembler/2007-03-19-NegValue.ll"},
   239  		{path: "../testdata/llvm/test/Assembler/2007-04-20-AlignedLoad.ll"},
   240  		{path: "../testdata/llvm/test/Assembler/2007-04-20-AlignedStore.ll"},
   241  		{path: "../testdata/llvm/test/Assembler/2007-04-25-AssemblerFoldExternWeak.ll"},
   242  		{path: "../testdata/llvm/test/Assembler/2007-05-21-Escape.ll"},
   243  		{path: "../testdata/llvm/test/Assembler/2007-07-19-ParamAttrAmbiguity.ll"},
   244  		{path: "../testdata/llvm/test/Assembler/2007-09-10-AliasFwdRef.ll"},
   245  		{path: "../testdata/llvm/test/Assembler/2007-09-29-GC.ll"},
   246  		{path: "../testdata/llvm/test/Assembler/2007-12-11-AddressSpaces.ll"},
   247  		{path: "../testdata/llvm/test/Assembler/2008-01-11-VarargAttrs.ll"},
   248  		{path: "../testdata/llvm/test/Assembler/2008-07-10-APInt.ll"},
   249  		{path: "../testdata/llvm/test/Assembler/2008-09-02-FunctionNotes.ll"},
   250  		{path: "../testdata/llvm/test/Assembler/2008-09-29-RetAttr.ll"},
   251  		{path: "../testdata/llvm/test/Assembler/2008-10-14-QuoteInName.ll"},
   252  		{path: "../testdata/llvm/test/Assembler/2009-02-01-UnnamedForwardRef.ll"},
   253  		{path: "../testdata/llvm/test/Assembler/2009-02-28-CastOpc.ll"},
   254  		{path: "../testdata/llvm/test/Assembler/2009-02-28-StripOpaqueName.ll"},
   255  		{path: "../testdata/llvm/test/Assembler/2009-03-24-ZextConstantExpr.ll"},
   256  		{path: "../testdata/llvm/test/Assembler/2009-07-24-ZeroArgGEP.ll"},
   257  		{path: "../testdata/llvm/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll"},
   258  		{path: "../testdata/llvm/test/Assembler/addrspacecast-alias.ll"},
   259  		{path: "../testdata/llvm/test/Assembler/aggregate-return-single-value.ll"},
   260  		{path: "../testdata/llvm/test/Assembler/alias-use-list-order.ll"},
   261  		{path: "../testdata/llvm/test/Assembler/align-inst.ll"},
   262  		{path: "../testdata/llvm/test/Assembler/alignstack.ll"},
   263  		{path: "../testdata/llvm/test/Assembler/alloca-addrspace-elems.ll"},
   264  		{path: "../testdata/llvm/test/Assembler/alloca-addrspace0.ll"},
   265  		{path: "../testdata/llvm/test/Assembler/alloca-size-one.ll"},
   266  		{path: "../testdata/llvm/test/Assembler/anon-functions.ll"},
   267  		{path: "../testdata/llvm/test/Assembler/atomic.ll"},
   268  		{path: "../testdata/llvm/test/Assembler/auto_upgrade_intrinsics.ll"},
   269  		{path: "../testdata/llvm/test/Assembler/auto_upgrade_nvvm_intrinsics.ll"},
   270  		{path: "../testdata/llvm/test/Assembler/autoupgrade-thread-pointer.ll"},
   271  		{path: "../testdata/llvm/test/Assembler/bcwrap.ll"},
   272  		{path: "../testdata/llvm/test/Assembler/comment.ll"},
   273  		{path: "../testdata/llvm/test/Assembler/ConstantExprFoldCast.ll"},
   274  		{path: "../testdata/llvm/test/Assembler/ConstantExprFoldSelect.ll"},
   275  		{path: "../testdata/llvm/test/Assembler/ConstantExprNoFold.ll"},
   276  		{path: "../testdata/llvm/test/Assembler/datalayout-alloca-addrspace.ll"},
   277  		{path: "../testdata/llvm/test/Assembler/datalayout-program-addrspace.ll"},
   278  		{path: "../testdata/llvm/test/Assembler/debug-info.ll"},
   279  		{path: "../testdata/llvm/test/Assembler/debug-label-bitcode.ll"},
   280  		{path: "../testdata/llvm/test/Assembler/dicompileunit.ll"},
   281  		{path: "../testdata/llvm/test/Assembler/dicompositetype-members.ll"},
   282  		{path: "../testdata/llvm/test/Assembler/DIEnumerator.ll"},
   283  		{path: "../testdata/llvm/test/Assembler/diexpression.ll"},
   284  		{path: "../testdata/llvm/test/Assembler/difile-escaped-chars.ll"},
   285  		{path: "../testdata/llvm/test/Assembler/diglobalvariable.ll"},
   286  		{path: "../testdata/llvm/test/Assembler/DIGlobalVariableExpression.ll"},
   287  		{path: "../testdata/llvm/test/Assembler/diimportedentity.ll"},
   288  		{path: "../testdata/llvm/test/Assembler/dilexicalblock.ll"},
   289  		{path: "../testdata/llvm/test/Assembler/dilocalvariable-arg-large.ll"},
   290  		{path: "../testdata/llvm/test/Assembler/dilocalvariable.ll"},
   291  		{path: "../testdata/llvm/test/Assembler/dilocation.ll"},
   292  		{path: "../testdata/llvm/test/Assembler/DIMacroFile.ll"},
   293  		{path: "../testdata/llvm/test/Assembler/dimodule.ll"},
   294  		{path: "../testdata/llvm/test/Assembler/dinamespace.ll"},
   295  		{path: "../testdata/llvm/test/Assembler/diobjcproperty.ll"},
   296  		{path: "../testdata/llvm/test/Assembler/distinct-mdnode.ll"},
   297  		{path: "../testdata/llvm/test/Assembler/disubprogram.ll"},
   298  		{path: "../testdata/llvm/test/Assembler/disubrange-empty-array.ll"},
   299  		{path: "../testdata/llvm/test/Assembler/disubroutinetype.ll"},
   300  		{path: "../testdata/llvm/test/Assembler/ditemplateparameter.ll"},
   301  		{path: "../testdata/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll"},
   302  		{path: "../testdata/llvm/test/Assembler/drop-debug-info.ll"},
   303  		{path: "../testdata/llvm/test/Assembler/externally-initialized.ll"},
   304  		{path: "../testdata/llvm/test/Assembler/fast-math-flags.ll"},
   305  		{path: "../testdata/llvm/test/Assembler/flags.ll"},
   306  		{path: "../testdata/llvm/test/Assembler/generic-debug-node.ll"},
   307  
   308  		// getelementptr with index vector
   309  		{path: "../testdata/llvm/test/Assembler/getelementptr_vec_ce.ll"},
   310  
   311  		{path: "../testdata/llvm/test/Assembler/global-addrspace-forwardref.ll"},
   312  		{path: "../testdata/llvm/test/Assembler/globalvariable-attributes.ll"},
   313  		{path: "../testdata/llvm/test/Assembler/half-constprop.ll"},
   314  		{path: "../testdata/llvm/test/Assembler/half-conv.ll"},
   315  		{path: "../testdata/llvm/test/Assembler/half.ll"},
   316  		{path: "../testdata/llvm/test/Assembler/huge-array.ll"},
   317  		{path: "../testdata/llvm/test/Assembler/ifunc-dsolocal.ll"},
   318  		{path: "../testdata/llvm/test/Assembler/ifunc-use-list-order.ll"},
   319  		{path: "../testdata/llvm/test/Assembler/inalloca.ll"},
   320  		{path: "../testdata/llvm/test/Assembler/incorrect-tdep-attrs-parsing.ll"},
   321  		{path: "../testdata/llvm/test/Assembler/insertextractvalue.ll"},
   322  		{path: "../testdata/llvm/test/Assembler/large-comdat.ll"},
   323  		{path: "../testdata/llvm/test/Assembler/local-unnamed-addr.ll"},
   324  		{path: "../testdata/llvm/test/Assembler/max-inttype.ll"},
   325  		{path: "../testdata/llvm/test/Assembler/metadata-decl.ll"},
   326  		{path: "../testdata/llvm/test/Assembler/metadata-function-local.ll"},
   327  		{path: "../testdata/llvm/test/Assembler/metadata-null-operands.ll"},
   328  		{path: "../testdata/llvm/test/Assembler/metadata.ll"},
   329  		{path: "../testdata/llvm/test/Assembler/MultipleReturnValueType.ll"},
   330  		{path: "../testdata/llvm/test/Assembler/musttail.ll"},
   331  		{path: "../testdata/llvm/test/Assembler/named-metadata.ll"},
   332  		{path: "../testdata/llvm/test/Assembler/no-mdstring-upgrades.ll"},
   333  		{path: "../testdata/llvm/test/Assembler/numbered-values.ll"},
   334  		{path: "../testdata/llvm/test/Assembler/select.ll"},
   335  		{path: "../testdata/llvm/test/Assembler/short-hexpair.ll"},
   336  		{path: "../testdata/llvm/test/Assembler/source-filename-backslash.ll"},
   337  		{path: "../testdata/llvm/test/Assembler/source-filename.ll"},
   338  		//{path: "../testdata/llvm/test/Assembler/thinlto-summary.ll"}, // TODO: add support for ThinLTO module summaries.
   339  		{path: "../testdata/llvm/test/Assembler/tls-models.ll"},
   340  		{path: "../testdata/llvm/test/Assembler/token.ll"},
   341  		{path: "../testdata/llvm/test/Assembler/unnamed-addr.ll"},
   342  		{path: "../testdata/llvm/test/Assembler/unnamed-alias.ll"},
   343  		{path: "../testdata/llvm/test/Assembler/unnamed.ll"},
   344  		{path: "../testdata/llvm/test/Assembler/uselistorder_bb.ll"},
   345  		{path: "../testdata/llvm/test/Assembler/uselistorder.ll"},
   346  		{path: "../testdata/llvm/test/Assembler/vbool-cmp.ll"},
   347  		{path: "../testdata/llvm/test/Assembler/vector-cmp.ll"},
   348  		{path: "../testdata/llvm/test/Assembler/vector-select.ll"},
   349  		{path: "../testdata/llvm/test/Assembler/vector-shift.ll"},
   350  		{path: "../testdata/llvm/test/Assembler/x86mmx.ll"},
   351  
   352  		// LLVM test/Bitcode.
   353  		{path: "../testdata/llvm/test/Bitcode/callbr.ll"},
   354  		{path: "../testdata/llvm/test/Bitcode/disubrange.ll"},
   355  
   356  		// LLVM test/CodeGen.
   357  		{path: "../testdata/llvm/test/CodeGen/X86/extractps.ll"},
   358  
   359  		// LLVM test/DebugInfo/Generic.
   360  		{path: "../testdata/llvm/test/DebugInfo/Generic/constant-pointers.ll"},
   361  		{path: "../testdata/llvm/test/DebugInfo/Generic/debug-info-enum.ll"},
   362  		{path: "../testdata/llvm/test/DebugInfo/Generic/debug-label-mi.ll"},
   363  		{path: "../testdata/llvm/test/DebugInfo/Generic/debug-names-linkage-name.ll"},
   364  		{path: "../testdata/llvm/test/DebugInfo/Generic/gmlt_profiling.ll"},
   365  		{path: "../testdata/llvm/test/DebugInfo/Generic/invalid.ll"},
   366  		{path: "../testdata/llvm/test/DebugInfo/Generic/template-recursive-void.ll"},
   367  
   368  		// LLVM test/DebugInfo.
   369  		{path: "../testdata/llvm/test/DebugInfo/check-debugify-preserves-analyses.ll"},
   370  		{path: "../testdata/llvm/test/DebugInfo/cross-cu-scope.ll"},
   371  		{path: "../testdata/llvm/test/DebugInfo/debugify-bogus-dbg-value.ll"},
   372  		{path: "../testdata/llvm/test/DebugInfo/debugify-each.ll"},
   373  		{path: "../testdata/llvm/test/DebugInfo/debugify-export.ll"},
   374  		{path: "../testdata/llvm/test/DebugInfo/debugify.ll"},
   375  		{path: "../testdata/llvm/test/DebugInfo/debugify-report-missing-locs-only.ll"},
   376  		{path: "../testdata/llvm/test/DebugInfo/dwo.ll"},
   377  		{path: "../testdata/llvm/test/DebugInfo/macro_link.ll"},
   378  		{path: "../testdata/llvm/test/DebugInfo/omit-empty.ll"},
   379  		{path: "../testdata/llvm/test/DebugInfo/pr34186.ll"},
   380  		{path: "../testdata/llvm/test/DebugInfo/pr34672.ll"},
   381  		{path: "../testdata/llvm/test/DebugInfo/skeletoncu.ll"},
   382  		{path: "../testdata/llvm/test/DebugInfo/strip-DIGlobalVariable.ll"},
   383  		{path: "../testdata/llvm/test/DebugInfo/strip-loop-metadata.ll"},
   384  		{path: "../testdata/llvm/test/DebugInfo/strip-module-flags.ll"},
   385  		{path: "../testdata/llvm/test/DebugInfo/unrolled-loop-remainder.ll"},
   386  
   387  		// LLVM test/DebugInfo/X86.
   388  		{path: "../testdata/llvm/test/DebugInfo/X86/clang-module.ll"},
   389  		{path: "../testdata/llvm/test/DebugInfo/X86/debug-ranges-offset.ll"},
   390  		{path: "../testdata/llvm/test/DebugInfo/X86/DIModuleContext.ll"},
   391  		{path: "../testdata/llvm/test/DebugInfo/X86/DIModule.ll"},
   392  		{path: "../testdata/llvm/test/DebugInfo/X86/dw_op_minus.ll"},
   393  		{path: "../testdata/llvm/test/DebugInfo/X86/gnu-public-names-empty.ll"},
   394  		{path: "../testdata/llvm/test/DebugInfo/X86/objc-property-void.ll"},
   395  		{path: "../testdata/llvm/test/DebugInfo/X86/safestack-byval.ll"},
   396  		{path: "../testdata/llvm/test/DebugInfo/X86/sdag-combine.ll"},
   397  		{path: "../testdata/llvm/test/DebugInfo/X86/stack-value-dwarf2.ll"},
   398  
   399  		// LLVM 12.0.
   400  		//
   401  		// * 'dso_local_equivalent' constant.
   402  		{path: "../testdata/llvm/test/Bitcode/dso_local_equivalent.ll"},
   403  
   404  		// LLVM 12.0.
   405  		//
   406  		// * 'DIStringType' metadata node.
   407  		{path: "../testdata/llvm/test/DebugInfo/X86/distringtype.ll"},
   408  
   409  		// LLVM 14.0.
   410  		//
   411  		// * 'no_cfi' constant.
   412  		{path: "../testdata/llvm/test/Bitcode/nocfivalue.ll"},
   413  		//
   414  		// * 'DIImportedEntity.elements' metadata field
   415  		{path: "../testdata/llvm/test/Bitcode/DIImportedEntity_elements.ll"},
   416  
   417  		// Coreutils.
   418  		{path: "../testdata/coreutils/test/[.ll"},
   419  		{path: "../testdata/coreutils/test/b2sum.ll"},
   420  		{path: "../testdata/coreutils/test/base32.ll"},
   421  		{path: "../testdata/coreutils/test/base64.ll"},
   422  		{path: "../testdata/coreutils/test/basename.ll"},
   423  		{path: "../testdata/coreutils/test/cat.ll"},
   424  		{path: "../testdata/coreutils/test/chcon.ll"},
   425  		{path: "../testdata/coreutils/test/chgrp.ll"},
   426  		{path: "../testdata/coreutils/test/chmod.ll"},
   427  		{path: "../testdata/coreutils/test/chown.ll"},
   428  		{path: "../testdata/coreutils/test/chroot.ll"},
   429  		{path: "../testdata/coreutils/test/cksum.ll"},
   430  		{path: "../testdata/coreutils/test/comm.ll"},
   431  		{path: "../testdata/coreutils/test/cp.ll"},
   432  		{path: "../testdata/coreutils/test/csplit.ll"},
   433  		{path: "../testdata/coreutils/test/cut.ll"},
   434  		{path: "../testdata/coreutils/test/date.ll"},
   435  		{path: "../testdata/coreutils/test/dd.ll"},
   436  		{path: "../testdata/coreutils/test/df.ll"},
   437  		{path: "../testdata/coreutils/test/dir.ll"},
   438  		{path: "../testdata/coreutils/test/dircolors.ll"},
   439  		{path: "../testdata/coreutils/test/dirname.ll"},
   440  		{path: "../testdata/coreutils/test/du.ll"},
   441  		{path: "../testdata/coreutils/test/echo.ll"},
   442  		{path: "../testdata/coreutils/test/env.ll"},
   443  		{path: "../testdata/coreutils/test/expand.ll"},
   444  		{path: "../testdata/coreutils/test/expr.ll"},
   445  		{path: "../testdata/coreutils/test/factor.ll"},
   446  		{path: "../testdata/coreutils/test/false.ll"},
   447  		{path: "../testdata/coreutils/test/fmt.ll"},
   448  		{path: "../testdata/coreutils/test/fold.ll"},
   449  		{path: "../testdata/coreutils/test/getlimits.ll"},
   450  		{path: "../testdata/coreutils/test/ginstall.ll"},
   451  		{path: "../testdata/coreutils/test/groups.ll"},
   452  		{path: "../testdata/coreutils/test/head.ll"},
   453  		{path: "../testdata/coreutils/test/hostid.ll"},
   454  		{path: "../testdata/coreutils/test/id.ll"},
   455  		{path: "../testdata/coreutils/test/join.ll"},
   456  		{path: "../testdata/coreutils/test/kill.ll"},
   457  		{path: "../testdata/coreutils/test/link.ll"},
   458  		{path: "../testdata/coreutils/test/ln.ll"},
   459  		{path: "../testdata/coreutils/test/logname.ll"},
   460  		{path: "../testdata/coreutils/test/ls.ll"},
   461  		{path: "../testdata/coreutils/test/make-prime-list.ll"},
   462  		{path: "../testdata/coreutils/test/md5sum.ll"},
   463  		{path: "../testdata/coreutils/test/mkdir.ll"},
   464  		{path: "../testdata/coreutils/test/mkfifo.ll"},
   465  		{path: "../testdata/coreutils/test/mknod.ll"},
   466  		{path: "../testdata/coreutils/test/mktemp.ll"},
   467  		{path: "../testdata/coreutils/test/mv.ll"},
   468  		{path: "../testdata/coreutils/test/nice.ll"},
   469  		{path: "../testdata/coreutils/test/nl.ll"},
   470  		{path: "../testdata/coreutils/test/nohup.ll"},
   471  		{path: "../testdata/coreutils/test/nproc.ll"},
   472  		{path: "../testdata/coreutils/test/numfmt.ll"},
   473  		{path: "../testdata/coreutils/test/od.ll"},
   474  		{path: "../testdata/coreutils/test/paste.ll"},
   475  		{path: "../testdata/coreutils/test/pathchk.ll"},
   476  		{path: "../testdata/coreutils/test/pinky.ll"},
   477  		{path: "../testdata/coreutils/test/pr.ll"},
   478  		{path: "../testdata/coreutils/test/printenv.ll"},
   479  		{path: "../testdata/coreutils/test/printf.ll"},
   480  		{path: "../testdata/coreutils/test/ptx.ll"},
   481  		{path: "../testdata/coreutils/test/pwd.ll"},
   482  		{path: "../testdata/coreutils/test/readlink.ll"},
   483  		{path: "../testdata/coreutils/test/realpath.ll"},
   484  		{path: "../testdata/coreutils/test/rm.ll"},
   485  		{path: "../testdata/coreutils/test/rmdir.ll"},
   486  		{path: "../testdata/coreutils/test/runcon.ll"},
   487  		{path: "../testdata/coreutils/test/seq.ll"},
   488  		{path: "../testdata/coreutils/test/sha1sum.ll"},
   489  		{path: "../testdata/coreutils/test/sha224sum.ll"},
   490  		{path: "../testdata/coreutils/test/sha256sum.ll"},
   491  		{path: "../testdata/coreutils/test/sha384sum.ll"},
   492  		{path: "../testdata/coreutils/test/sha512sum.ll"},
   493  		{path: "../testdata/coreutils/test/shred.ll"},
   494  		{path: "../testdata/coreutils/test/shuf.ll"},
   495  		{path: "../testdata/coreutils/test/sleep.ll"},
   496  		{path: "../testdata/coreutils/test/sort.ll"},
   497  		{path: "../testdata/coreutils/test/split.ll"},
   498  		{path: "../testdata/coreutils/test/stat.ll"},
   499  		{path: "../testdata/coreutils/test/stdbuf.ll"},
   500  		{path: "../testdata/coreutils/test/stty.ll"},
   501  		{path: "../testdata/coreutils/test/sum.ll"},
   502  		{path: "../testdata/coreutils/test/sync.ll"},
   503  		{path: "../testdata/coreutils/test/tac.ll"},
   504  		{path: "../testdata/coreutils/test/tail.ll"},
   505  		{path: "../testdata/coreutils/test/tee.ll"},
   506  		{path: "../testdata/coreutils/test/test.ll"},
   507  		{path: "../testdata/coreutils/test/timeout.ll"},
   508  		{path: "../testdata/coreutils/test/touch.ll"},
   509  		{path: "../testdata/coreutils/test/tr.ll"},
   510  		{path: "../testdata/coreutils/test/true.ll"},
   511  		{path: "../testdata/coreutils/test/truncate.ll"},
   512  		{path: "../testdata/coreutils/test/tsort.ll"},
   513  		{path: "../testdata/coreutils/test/tty.ll"},
   514  		{path: "../testdata/coreutils/test/uname.ll"},
   515  		{path: "../testdata/coreutils/test/unexpand.ll"},
   516  		{path: "../testdata/coreutils/test/uniq.ll"},
   517  		{path: "../testdata/coreutils/test/unlink.ll"},
   518  		{path: "../testdata/coreutils/test/uptime.ll"},
   519  		{path: "../testdata/coreutils/test/users.ll"},
   520  		{path: "../testdata/coreutils/test/vdir.ll"},
   521  		{path: "../testdata/coreutils/test/wc.ll"},
   522  		{path: "../testdata/coreutils/test/who.ll"},
   523  		{path: "../testdata/coreutils/test/whoami.ll"},
   524  		{path: "../testdata/coreutils/test/yes.ll"},
   525  
   526  		// SQLite.
   527  		{path: "../testdata/sqlite/test/shell.ll"},
   528  	}
   529  	hasTestdata := osutil.Exists("../testdata/llvm")
   530  	for _, g := range golden {
   531  		if filepath.HasPrefix(g.path, "../testdata") && !hasTestdata {
   532  			// Skip test cases from the llir/testdata submodule if not downloaded.
   533  			// Users may add this submodule using git clone --recursive.
   534  			continue
   535  		}
   536  		log.Printf("=== [ %s ] ===", g.path)
   537  		m, err := ParseFile(g.path)
   538  		if err != nil {
   539  			t.Errorf("unable to parse %q into AST; %+v", g.path, err)
   540  			continue
   541  		}
   542  		path := g.path
   543  		hasGolden := osutil.Exists(g.path + ".golden")
   544  		if hasGolden {
   545  			path = g.path + ".golden"
   546  		}
   547  		buf, err := ioutil.ReadFile(path)
   548  		if err != nil {
   549  			t.Errorf("unable to read %q; %+v", path, err)
   550  			continue
   551  		}
   552  		want := string(buf)
   553  		got := m.String()
   554  		if diff := cmp.Diff(want, got); diff != "" {
   555  			t.Errorf("module %q mismatch (-want +got):\n%s", path, diff)
   556  			continue
   557  		}
   558  		// Do round-trip test on golden test cases.
   559  		if hasGolden {
   560  			goldenPath := g.path + ".golden"
   561  			m, err := ParseFile(goldenPath)
   562  			if err != nil {
   563  				t.Errorf("unable to parse %q into AST; %+v", goldenPath, err)
   564  				continue
   565  			}
   566  			want := string(buf)
   567  			got := m.String()
   568  			if diff := cmp.Diff(want, got); diff != "" {
   569  				t.Errorf("module %q mismatch (-want +got):\n%s", goldenPath, diff)
   570  				continue
   571  			}
   572  		}
   573  	}
   574  }