[opaque pointer type] Add textual IR support for explicit type parameter for global...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 11 Sep 2015 03:22:04 +0000 (03:22 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 11 Sep 2015 03:22:04 +0000 (03:22 +0000)
commit21f77df7b644f471dc6f9cc7abaa52667e471650
tree0157391eba974278f7006498f3ada1dd0b23f643
parenta6f58ad82d6a8728096bf4690fa4b9e4f99241ae
[opaque pointer type] Add textual IR support for explicit type parameter for global aliases

update.py:
import fileinput
import sys
import re

alias_match_prefix = r"(.*(?:=|:|^)\s*(?:external |)(?:(?:private|internal|linkonce|linkonce_odr|weak|weak_odr|common|appending|extern_weak|available_externally) )?(?:default |hidden |protected )?(?:dllimport |dllexport )?(?:unnamed_addr |)(?:thread_local(?:\([a-z]*\))? )?alias"
plain = re.compile(alias_match_prefix + r" (.*?))(| addrspace\(\d+\) *)\*($| *(?:%|@|null|undef|blockaddress|addrspacecast|\[\[[a-zA-Z]|\{\{).*$)")
cast  = re.compile(alias_match_prefix + r") ((?:bitcast|inttoptr|addrspacecast)\s*\(.* to (.*?)(| addrspace\(\d+\) *)\*\)\s*(?:;.*)?$)")
gep   = re.compile(alias_match_prefix + r") ((?:getelementptr)\s*(?:inbounds)?\s*\((?P<type>.*), (?P=type)(?:\s*addrspace\(\d+\)\s*)?\* .*\)\s*(?:;.*)?$)")

def conv(line):
  m = re.match(cast, line)
  if m:
    return m.group(1) + " " + m.group(3) + ", " + m.group(2)
  m = re.match(gep, line)
  if m:
    return m.group(1) + " " + m.group(3) + ", " + m.group(2)
  m = re.match(plain, line)
  if m:
    return m.group(1) + ", " + m.group(2) + m.group(3) + "*" + m.group(4) + "\n"
  return line

for line in sys.stdin:
  sys.stdout.write(conv(line))

apply.sh:
for name in "$@"
do
  python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name"
  rm -f "$name.tmp"
done

The actual commands:
From llvm/src:
find test/ -name *.ll | xargs ./apply.sh
From llvm/src/tools/clang:
find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}"
From llvm/src/tools/polly:
find test/ -name *.ll | xargs ./apply.sh

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247378 91177308-0d34-0410-b5e6-96231b3b80d8
116 files changed:
lib/AsmParser/LLParser.cpp
lib/IR/AsmWriter.cpp
test/Analysis/BasicAA/2007-11-05-SizeCrash.ll
test/Analysis/BasicAA/2007-12-08-OutOfBoundsCrash.ll
test/Assembler/2007-09-10-AliasFwdRef.ll
test/Assembler/ConstantExprNoFold.ll
test/Assembler/addrspacecast-alias.ll
test/Assembler/alias-redefinition.ll
test/Assembler/alias-use-list-order.ll
test/Assembler/anon-functions.ll
test/Assembler/internal-hidden-alias.ll
test/Assembler/internal-protected-alias.ll
test/Assembler/invalid-alias-mismatched-explicit-type.ll [new file with mode: 0644]
test/Assembler/invalid-fwdref2.ll
test/Assembler/invalid-uselistorder-indexes-duplicated.ll
test/Assembler/invalid-uselistorder-indexes-one.ll
test/Assembler/invalid-uselistorder-indexes-ordered.ll
test/Assembler/invalid-uselistorder-indexes-range.ll
test/Assembler/invalid-uselistorder-indexes-toofew.ll
test/Assembler/invalid-uselistorder-indexes-toomany.ll
test/Assembler/private-hidden-alias.ll
test/Assembler/private-protected-alias.ll
test/Assembler/unnamed-alias.ll
test/Assembler/uselistorder.ll
test/Bitcode/compatibility-3.6.ll
test/Bitcode/compatibility-3.7.ll
test/Bitcode/compatibility.ll
test/Bitcode/highLevelStructure.3.2.ll
test/Bitcode/local-linkage-default-visibility.3.4.ll
test/Bitcode/old-aliases.ll
test/Bitcode/use-list-order.ll
test/BugPoint/replace-funcs-with-null.ll
test/CodeGen/AArch64/global-alignment.ll
test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll
test/CodeGen/ARM/aliases.ll
test/CodeGen/Generic/2009-03-17-LSR-APInt.ll
test/CodeGen/Mips/tls-alias.ll
test/CodeGen/PowerPC/alias.ll
test/CodeGen/X86/2007-09-06-ExtWeakAliasee.ll
test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll
test/CodeGen/X86/2008-03-14-SpillerCrash.ll
test/CodeGen/X86/aliases.ll
test/CodeGen/X86/avx512-mask-bugfix.ll [changed mode: 0755->0644]
test/CodeGen/X86/coff-comdat.ll
test/CodeGen/X86/dllexport-x86_64.ll
test/CodeGen/X86/dllexport.ll
test/CodeGen/X86/fast-isel-emutls.ll
test/CodeGen/X86/fast-isel-tls.ll
test/CodeGen/X86/pr22019.ll
test/CodeGen/X86/shift-avx2-crash.ll [changed mode: 0755->0644]
test/CodeGen/X86/x86-64-pic-10.ll
test/CodeGen/XCore/aliases.ll
test/DebugInfo/X86/elf-names.ll
test/DebugInfo/X86/pr12831.ll
test/DebugInfo/X86/sret.ll
test/Feature/alias2.ll
test/Feature/aliases.ll
test/Feature/comdat.ll
test/Instrumentation/AddressSanitizer/do-not-touch-comdat-global.ll
test/Instrumentation/DataFlowSanitizer/abilist.ll
test/Instrumentation/DataFlowSanitizer/prefix-rename.ll
test/Linker/2008-03-05-AliasReference.ll
test/Linker/2008-07-06-AliasFnDecl.ll
test/Linker/2008-07-06-AliasWeakDest.ll
test/Linker/Inputs/PR8300.b.ll
test/Linker/Inputs/alias.ll
test/Linker/Inputs/comdat5.ll
test/Linker/Inputs/comdat8.ll
test/Linker/Inputs/type-unique-alias.ll
test/Linker/Inputs/visibility.ll
test/Linker/alias.ll
test/Linker/comdat6.ll
test/Linker/comdat8.ll
test/Linker/comdat9.ll
test/Linker/constructor-comdat.ll
test/Linker/pr21494.ll
test/Linker/type-unique-alias.ll
test/Linker/unnamed-addr1-a.ll
test/Linker/unnamed-addr1-b.ll
test/Linker/visibility.ll
test/Object/X86/nm-ir.ll
test/Other/extract-alias.ll
test/Other/llvm-nm-without-aliases.ll
test/SymbolRewriter/rewrite.ll
test/Transforms/ConstantMerge/merge-both.ll
test/Transforms/GVN/2009-03-10-PREOnVoid.ll
test/Transforms/GlobalDCE/2009-01-05-DeadAliases.ll
test/Transforms/GlobalDCE/2009-02-17-AliasUsesAliasee.ll
test/Transforms/GlobalDCE/pr20981.ll
test/Transforms/GlobalOpt/2009-02-15-BitcastAlias.ll
test/Transforms/GlobalOpt/2009-02-15-ResolveAlias.ll
test/Transforms/GlobalOpt/alias-resolve.ll
test/Transforms/GlobalOpt/alias-used-address-space.ll
test/Transforms/GlobalOpt/alias-used-section.ll
test/Transforms/GlobalOpt/alias-used.ll
test/Transforms/InstCombine/2007-09-10-AliasConstFold.ll
test/Transforms/InstCombine/2007-09-17-AliasConstFold2.ll
test/Transforms/InstCombine/alias-recursion.ll
test/Transforms/InstCombine/bitcast-alias-function.ll
test/Transforms/InstCombine/constant-fold-alias.ll
test/Transforms/InstCombine/objsize-address-space.ll
test/Transforms/InstCombine/objsize.ll
test/Transforms/Internalize/2009-01-05-InternalizeAliases.ll
test/Transforms/Internalize/comdat.ll
test/Transforms/Internalize/local-visibility.ll
test/Transforms/LowerBitSets/function.ll
test/Transforms/LowerBitSets/simple.ll
test/Transforms/MetaRenamer/metarenamer.ll
test/Transforms/SCCP/global-alias-constprop.ll
test/Verifier/alias.ll
test/Verifier/bitcast-alias-address-space.ll
test/tools/gold/X86/Inputs/comdat.ll
test/tools/gold/X86/alias.ll
test/tools/gold/X86/bad-alias.ll
test/tools/gold/X86/comdat.ll
test/tools/llvm-split/alias.ll