[llvm-branch-commits] [lld] 73ea825 - [ELF] Make dot in .tbss correct

2021-08-04 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-08-04T09:06:59-07:00
New Revision: 73ea8254d2d7177e84814688a4523144bdbd2fbb

URL: 
https://github.com/llvm/llvm-project/commit/73ea8254d2d7177e84814688a4523144bdbd2fbb
DIFF: 
https://github.com/llvm/llvm-project/commit/73ea8254d2d7177e84814688a4523144bdbd2fbb.diff

LOG: [ELF] Make dot in .tbss correct

GNU ld doesn't support multiple SHF_TLS SHT_NOBITS output sections (it restores
the address after an SHF_TLS SHT_NOBITS section, so consecutive SHF_TLS
SHT_NOBITS sections will have conflicting address ranges).

That said, `threadBssOffset` implements limited support for consecutive SHF_TLS
SHT_NOBITS sections. (SHF_TLS SHT_PROGBITS following a SHF_TLS SHT_NOBITS can 
still be
incorrect.)

`.` in an output section description of an SHF_TLS SHT_NOBITS section is
incorrect. (https://lists.llvm.org/pipermail/llvm-dev/2021-July/151974.html)

This patch saves the end address of the previous tbss section in
`ctx->tbssAddr`, changes `dot` in the beginning of `assignOffset` so
that `.` evaluation will be correct.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D107208

(cherry picked from commit 9bd29a73d17add45234a35de5f6ad7ca8321f7f9)

Added: 


Modified: 
lld/ELF/LinkerScript.cpp
lld/ELF/LinkerScript.h
lld/test/ELF/linkerscript/tbss.s

Removed: 




diff  --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index a938984ad945e..01785f39ed759 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -849,17 +849,8 @@ void LinkerScript::diagnoseOrphanHandling() const {
 }
 
 uint64_t LinkerScript::advance(uint64_t size, unsigned alignment) {
-  bool isTbss =
-  (ctx->outSec->flags & SHF_TLS) && ctx->outSec->type == SHT_NOBITS;
-  uint64_t start = isTbss ? dot + ctx->threadBssOffset : dot;
-  start = alignTo(start, alignment);
-  uint64_t end = start + size;
-
-  if (isTbss)
-ctx->threadBssOffset = end - dot;
-  else
-dot = end;
-  return end;
+  dot = alignTo(dot, alignment) + size;
+  return dot;
 }
 
 void LinkerScript::output(InputSection *s) {
@@ -931,13 +922,24 @@ static OutputSection *findFirstSection(PhdrEntry *load) {
 // This function assigns offsets to input sections and an output section
 // for a single sections command (e.g. ".text { *(.text); }").
 void LinkerScript::assignOffsets(OutputSection *sec) {
+  const bool isTbss = (sec->flags & SHF_TLS) && sec->type == SHT_NOBITS;
   const bool sameMemRegion = ctx->memRegion == sec->memRegion;
   const bool prevLMARegionIsDefault = ctx->lmaRegion == nullptr;
   const uint64_t savedDot = dot;
   ctx->memRegion = sec->memRegion;
   ctx->lmaRegion = sec->lmaRegion;
 
-  if (sec->flags & SHF_ALLOC) {
+  if (!(sec->flags & SHF_ALLOC)) {
+// Non-SHF_ALLOC sections have zero addresses.
+dot = 0;
+  } else if (isTbss) {
+// Allow consecutive SHF_TLS SHT_NOBITS output sections. The address range
+// starts from the end address of the previous tbss section.
+if (ctx->tbssAddr == 0)
+  ctx->tbssAddr = dot;
+else
+  dot = ctx->tbssAddr;
+  } else {
 if (ctx->memRegion)
   dot = ctx->memRegion->curPos;
 if (sec->addrExpr)
@@ -950,9 +952,6 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
 if (ctx->memRegion && ctx->memRegion->curPos < dot)
   expandMemoryRegion(ctx->memRegion, dot - ctx->memRegion->curPos,
  ctx->memRegion->name, sec->name);
-  } else {
-// Non-SHF_ALLOC sections have zero addresses.
-dot = 0;
   }
 
   switchTo(sec);
@@ -1008,8 +1007,13 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
 
   // Non-SHF_ALLOC sections do not affect the addresses of other OutputSections
   // as they are not part of the process image.
-  if (!(sec->flags & SHF_ALLOC))
+  if (!(sec->flags & SHF_ALLOC)) {
 dot = savedDot;
+  } else if (isTbss) {
+// NOBITS TLS sections are similar. Additionally save the end address.
+ctx->tbssAddr = dot;
+dot = savedDot;
+  }
 }
 
 static bool isDiscardable(OutputSection &sec) {

diff  --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 0592c52acb84d..d2487ae0f9d28 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -247,11 +247,11 @@ class LinkerScript final {
   // not be used outside of the scope of a call to the above functions.
   struct AddressState {
 AddressState();
-uint64_t threadBssOffset = 0;
 OutputSection *outSec = nullptr;
 MemoryRegion *memRegion = nullptr;
 MemoryRegion *lmaRegion = nullptr;
 uint64_t lmaOffset = 0;
+uint64_t tbssAddr = 0;
   };
 
   llvm::DenseMap nameToOutputSection;

diff  --git a/lld/test/ELF/linkerscript/tbss.s 
b/lld/test/ELF/linkerscript/tbss.s
index 1560ad5d039a2..1113a797b9170 100644
--- a/lld/test/ELF/linkerscript/tbss.s
+++ b/lld/test/ELF/linkerscript/tbss.s
@@ -1,42 +1,43 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-

[llvm-branch-commits] [lld] 7e69b17 - [ELF][test] Improve .symver & --version-script tests

2021-08-04 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-08-04T09:17:51-07:00
New Revision: 7e69b1728c2317610d3e9d82d52ca7ad38adb034

URL: 
https://github.com/llvm/llvm-project/commit/7e69b1728c2317610d3e9d82d52ca7ad38adb034
DIFF: 
https://github.com/llvm/llvm-project/commit/7e69b1728c2317610d3e9d82d52ca7ad38adb034.diff

LOG: [ELF][test] Improve .symver & --version-script tests

And delete redundant tests.

Added: 
lld/test/ELF/version-script-undef.s

Modified: 
lld/test/ELF/partition-synthetic-sections.s
lld/test/ELF/verneed.s
lld/test/ELF/version-script-symver.s
lld/test/ELF/version-symbol-undef.s

Removed: 
lld/test/ELF/undef-version-script.s
lld/test/ELF/version-script-glob.s
lld/test/ELF/version-script-hide-so-symbol.s
lld/test/ELF/version-script-locals.s
lld/test/ELF/version-script-twice.s



diff  --git a/lld/test/ELF/partition-synthetic-sections.s 
b/lld/test/ELF/partition-synthetic-sections.s
index e959d96583f7..3654b3cf5c58 100644
--- a/lld/test/ELF/partition-synthetic-sections.s
+++ b/lld/test/ELF/partition-synthetic-sections.s
@@ -3,7 +3,7 @@
 // REQUIRES: x86
 
 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o 
%t1.o
-// RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t1.script
+// RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t1.script
 // RUN: ld.lld -shared %t1.o --version-script %t1.script -o %t1.so -soname 
verneed1.so.0 -z separate-code
 
 // RUN: llvm-mc %s -o %t.o -filetype=obj --triple=x86_64-unknown-linux

diff  --git a/lld/test/ELF/verneed.s b/lld/test/ELF/verneed.s
index e5edaeeb6d07..6a90cc48e68f 100644
--- a/lld/test/ELF/verneed.s
+++ b/lld/test/ELF/verneed.s
@@ -1,6 +1,6 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o 
%t1.o
-# RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t.script
+# RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t.script
 # RUN: ld.lld -shared %t1.o --version-script %t.script -o %t1.so -soname 
verneed1.so.0
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed2.s -o 
%t2.o
 # RUN: ld.lld -shared %t2.o --version-script %t.script -o %t2.so -soname 
verneed2.so.0

diff  --git a/lld/test/ELF/version-script-glob.s 
b/lld/test/ELF/version-script-glob.s
deleted file mode 100644
index 0f2bd88875e2..
--- a/lld/test/ELF/version-script-glob.s
+++ /dev/null
@@ -1,23 +0,0 @@
-# REQUIRES: x86
-
-# RUN: echo "{ global: foo*; bar*; local: *; };" > %t.script
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: ld.lld -shared --version-script %t.script %t.o -o %t.so
-# RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s
-
-.globl foo1, bar1, zed1, local
-foo1:
-bar1:
-zed1:
-local:
-
-# CHECK:  foo1{{$}}
-# CHECK-NEXT: bar1{{$}}
-# CHECK-NOT:  {{.}}
-
-# RUN: echo "{ global : local; local: *; };" > %t1.script
-# RUN: ld.lld -shared --version-script %t1.script %t.o -o %t.so
-# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=LOCAL %s
-
-# LOCAL: local{{$}}
-# LOCAL-NOT: {{.}}

diff  --git a/lld/test/ELF/version-script-hide-so-symbol.s 
b/lld/test/ELF/version-script-hide-so-symbol.s
deleted file mode 100644
index ba33c68511d0..
--- a/lld/test/ELF/version-script-hide-so-symbol.s
+++ /dev/null
@@ -1,28 +0,0 @@
-# REQUIRES: x86
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-# RUN: ld.lld -shared %t.o -o %t2.so
-# RUN: echo "{ local: *; };" > %t.script
-# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so
-# RUN: llvm-readobj --dyn-syms %t.so | FileCheck %s
-
-# The symbol foo must be hidden. This matches bfd and gold and is
-# required to make it possible for a c++ library to hide its own
-# operator delete.
-
-# CHECK:  DynamicSymbols [
-# CHECK-NEXT:   Symbol {
-# CHECK-NEXT: Name:
-# CHECK-NEXT: Value: 0x0
-# CHECK-NEXT: Size: 0
-# CHECK-NEXT: Binding: Local
-# CHECK-NEXT: Type: None
-# CHECK-NEXT: Other: 0
-# CHECK-NEXT: Section: Undefined
-# CHECK-NEXT:   }
-# CHECK-NEXT: ]
-
-.global foo
-foo:
-   nop
-

diff  --git a/lld/test/ELF/version-script-locals.s 
b/lld/test/ELF/version-script-locals.s
deleted file mode 100644
index 119d4cc7bdd2..
--- a/lld/test/ELF/version-script-locals.s
+++ /dev/null
@@ -1,45 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-
-# RUN: echo "VERSION_1.0 { local: foo1; };" > %t.script
-# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
-# RUN: llvm-readobj --dyn-syms %t.so | FileCheck --check-prefix=EXACT %s
-# EXACT:  DynamicSymbols [
-# EXACT-NOT:  foo1
-# EXACT:  foo2
-# EXACT:  foo3
-# EXACT:  _start
-
-# RUN: echo "VERSION_1.0 { local: foo*; };" > %t.script
-# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
-# RUN: llvm-readobj --dyn-syms %t.so | FileCheck --check-prefix=WC %s
-# WC:  DynamicSymbo

[llvm-branch-commits] [lld] 17edcb3 - [ELF] Apply version script patterns to non-default version symbols

2021-08-04 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-08-04T09:18:02-07:00
New Revision: 17edcb3a6e131b84b8dc253fa950eec16dc47cc7

URL: 
https://github.com/llvm/llvm-project/commit/17edcb3a6e131b84b8dc253fa950eec16dc47cc7
DIFF: 
https://github.com/llvm/llvm-project/commit/17edcb3a6e131b84b8dc253fa950eec16dc47cc7.diff

LOG: [ELF] Apply version script patterns to non-default version symbols

Currently version script patterns are ignored for .symver produced
non-default version (single @) symbols. This makes such symbols
not localizable by `local:`, e.g.

```
.symver foo3_v1,foo3@v1
.globl foo_v1
foo3_v1:

ld.lld --version-script=a.ver -shared a.o
# In a.out, foo3@v1 is incorrectly exported.
```

This patch adds the support:

* Move `config->versionDefinitions[VER_NDX_LOCAL].patterns` to 
`config->versionDefinitions[versionId].localPatterns`
* Rename `config->versionDefinitions[versionId].patterns` to 
`config->versionDefinitions[versionId].nonLocalPatterns`
* Allow `findAllByVersion` to find non-default version symbols when 
`includeNonDefault` is true. (Note: `symtab` keys do not have `@@`)
* Make each pattern check both the unversioned `pat.name` and the versioned 
`${pat.name}@${v.name}`
* `localPatterns` can localize `${pat.name}@${v.name}`. `nonLocalPatterns` can 
prevent localization by assigning `verdefIndex` (before `parseSymbolVersion`).

---

If a user notices new `undefined symbol` errors with a version script containing
`local: *;`, the issue is likely due to a missing `global:` pattern.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D107234

Added: 
lld/test/ELF/version-script-symver-extern.s

Modified: 
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/ScriptParser.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h
lld/ELF/Symbols.cpp
lld/test/ELF/version-script-noundef.s
lld/test/ELF/version-script-symver.s

Removed: 
lld/test/ELF/version-script-extern-exact.s
lld/test/ELF/version-script-extern-wildcards.s
lld/test/ELF/version-script-extern.s



diff  --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index a996a815599a4..e1abb4dfab36a 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -86,7 +86,8 @@ struct SymbolVersion {
 struct VersionDefinition {
   llvm::StringRef name;
   uint16_t id;
-  std::vector patterns;
+  std::vector nonLocalPatterns;
+  std::vector localPatterns;
 };
 
 // This struct contains the global configuration for the linker.

diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 91e7df21a60ad..4197c6b115bbe 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1351,18 +1351,19 @@ static void readConfigs(opt::InputArgList &args) {
   }
 
   assert(config->versionDefinitions.empty());
-  config->versionDefinitions.push_back({"local", (uint16_t)VER_NDX_LOCAL, {}});
   config->versionDefinitions.push_back(
-  {"global", (uint16_t)VER_NDX_GLOBAL, {}});
+  {"local", (uint16_t)VER_NDX_LOCAL, {}, {}});
+  config->versionDefinitions.push_back(
+  {"global", (uint16_t)VER_NDX_GLOBAL, {}, {}});
 
   // If --retain-symbol-file is used, we'll keep only the symbols listed in
   // the file and discard all others.
   if (auto *arg = args.getLastArg(OPT_retain_symbols_file)) {
-config->versionDefinitions[VER_NDX_LOCAL].patterns.push_back(
+config->versionDefinitions[VER_NDX_LOCAL].nonLocalPatterns.push_back(
 {"*", /*isExternCpp=*/false, /*hasWildcard=*/true});
 if (Optional buffer = readFile(arg->getValue()))
   for (StringRef s : args::getLines(*buffer))
-config->versionDefinitions[VER_NDX_GLOBAL].patterns.push_back(
+config->versionDefinitions[VER_NDX_GLOBAL].nonLocalPatterns.push_back(
 {s, /*isExternCpp=*/false, /*hasWildcard=*/false});
   }
 

diff  --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 2c980eb810c77..1c743fd477471 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1496,9 +1496,9 @@ void ScriptParser::readAnonymousDeclaration() {
   std::vector globals;
   std::tie(locals, globals) = readSymbols();
   for (const SymbolVersion &pat : locals)
-config->versionDefinitions[VER_NDX_LOCAL].patterns.push_back(pat);
+config->versionDefinitions[VER_NDX_LOCAL].localPatterns.push_back(pat);
   for (const SymbolVersion &pat : globals)
-config->versionDefinitions[VER_NDX_GLOBAL].patterns.push_back(pat);
+config->versionDefinitions[VER_NDX_GLOBAL].nonLocalPatterns.push_back(pat);
 
   expect(";");
 }
@@ -1510,13 +1510,12 @@ void ScriptParser::readVersionDeclaration(StringRef 
verStr) {
   std::vector locals;
   std::vector globals;
   std::tie(locals, globals) = readSymbols();
-  for (const SymbolVersion &pat : locals)
-config->versionDefinitions[VER_NDX_LOCAL].patterns.push_back(pat);
 
   // Create a new version definition and add that to the global symbols.
   VersionDefinition ver;
   ver.name = verStr;
-  ver.patterns = gl

[llvm-branch-commits] [lld] 4783a6c - [ELF] Combine foo@v1 and foo with the same versionId if both are defined

2021-08-04 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2021-08-04T09:18:10-07:00
New Revision: 4783a6cdf0a9087212f517ce20e0e3a9cf39d6a4

URL: 
https://github.com/llvm/llvm-project/commit/4783a6cdf0a9087212f517ce20e0e3a9cf39d6a4
DIFF: 
https://github.com/llvm/llvm-project/commit/4783a6cdf0a9087212f517ce20e0e3a9cf39d6a4.diff

LOG: [ELF] Combine foo@v1 and foo with the same versionId if both are defined

Due to an assembler design flaw (IMO), `.symver foo,foo@v1` produces two 
symbols `foo` and `foo@v1` if `foo` is defined.

* `v1 {};` produces both `foo` and `foo@v1`, but GNU ld only produces `foo@v1`
* `v1 { foo; };` produces both `foo@@v1` and `foo@v1`, but GNU ld only produces 
`foo@v1`
* `v2 { foo; };` produces both `foo@@v2` and `foo@v1`, matching GNU ld. (Tested 
by symver.s)

This patch implements the GNU ld behavior by reusing the symbol redirection 
mechanism
in D92259. The new test symver-non-default.s checks the first two cases.

Without the patch, the second case will produce `foo@v1` and `foo@@v1` which
looks weird and makes foo unnecessarily default versioned.

Note: `.symver foo,foo@v1,remove` exists but the unfortunate `foo` will not go
away anytime soon.

Reviewed By: peter.smith

Differential Revision: https://reviews.llvm.org/D107235

Added: 
lld/test/ELF/symver-non-default.s

Modified: 
lld/ELF/Driver.cpp
lld/test/ELF/version-script-symver.s
lld/test/ELF/version-symbol-undef.s

Removed: 




diff  --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 4197c6b115bb..594c20016827 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -2070,23 +2070,37 @@ static void redirectSymbols(ArrayRef 
wrapped) {
 if (suffix1[0] != '@' || suffix1[1] == '@')
   continue;
 
-// Check whether the default version foo@@v1 exists. If it exists, the
-// symbol can be found by the name "foo" in the symbol table.
-Symbol *maybeDefault = symtab->find(name);
-if (!maybeDefault)
-  continue;
-const char *suffix2 = maybeDefault->getVersionSuffix();
-if (suffix2[0] != '@' || suffix2[1] != '@' ||
-strcmp(suffix1 + 1, suffix2 + 2) != 0)
+// Check the existing symbol foo. We have two special cases to handle:
+//
+// * There is a definition of foo@v1 and foo@@v1.
+// * There is a definition of foo@v1 and foo.
+Defined *sym2 = dyn_cast_or_null(symtab->find(name));
+if (!sym2)
   continue;
-
-// foo@v1 and foo@@v1 should be merged, so redirect foo@v1 to foo@@v1.
-map.try_emplace(sym, maybeDefault);
-// If both foo@v1 and foo@@v1 are defined and non-weak, report a duplicate
-// definition error.
-maybeDefault->resolve(*sym);
-// Eliminate foo@v1 from the symbol table.
-sym->symbolKind = Symbol::PlaceholderKind;
+const char *suffix2 = sym2->getVersionSuffix();
+if (suffix2[0] == '@' && suffix2[1] == '@' &&
+strcmp(suffix1 + 1, suffix2 + 2) == 0) {
+  // foo@v1 and foo@@v1 should be merged, so redirect foo@v1 to foo@@v1.
+  map.try_emplace(sym, sym2);
+  // If both foo@v1 and foo@@v1 are defined and non-weak, report a 
duplicate
+  // definition error.
+  sym2->resolve(*sym);
+  // Eliminate foo@v1 from the symbol table.
+  sym->symbolKind = Symbol::PlaceholderKind;
+} else if (auto *sym1 = dyn_cast(sym)) {
+  if (sym2->versionId > VER_NDX_GLOBAL
+  ? config->versionDefinitions[sym2->versionId].name == suffix1 + 1
+  : sym1->section == sym2->section && sym1->value == sym2->value) {
+// Due to an assembler design flaw, if foo is defined, .symver foo,
+// foo@v1 defines both foo and foo@v1. Unless foo is bound to a
+// 
diff erent version, GNU ld makes foo@v1 canonical and elimiates foo.
+// Emulate its behavior, otherwise we would have foo or foo@@v1 beside
+// foo@v1. foo@v1 and foo combining does not apply if they are not
+// defined in the same place.
+map.try_emplace(sym2, sym);
+sym2->symbolKind = Symbol::PlaceholderKind;
+  }
+}
   }
 
   if (map.empty())

diff  --git a/lld/test/ELF/symver-non-default.s 
b/lld/test/ELF/symver-non-default.s
new file mode 100644
index ..4923a5108018
--- /dev/null
+++ b/lld/test/ELF/symver-non-default.s
@@ -0,0 +1,69 @@
+# REQUIRES: x86
+## Test symbol resolution related to .symver produced non-default version 
symbols.
+
+# RUN: split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref.s -o %t/ref.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1.s -o %t/def1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def2.s -o %t/def2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def3.s -o %t/def3.o
+
+## foo@v1 & foo defined at the same location are combined.
+# RUN: ld.lld -shared --version-script=%t/ver1 %t/def1.o %t/ref.o -o %t1
+# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=CHECK1
+# RUN: ld.lld -shared --version-script=%t

[llvm-branch-commits] [llvm] 6d04cd4 - [Attributor] Change function internalization to not replace uses in internalized callers

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Joseph Huber
Date: 2021-08-04T16:35:01-07:00
New Revision: 6d04cd42ebf04907cb70574b59f9483959031839

URL: 
https://github.com/llvm/llvm-project/commit/6d04cd42ebf04907cb70574b59f9483959031839
DIFF: 
https://github.com/llvm/llvm-project/commit/6d04cd42ebf04907cb70574b59f9483959031839.diff

LOG: [Attributor] Change function internalization to not replace uses in 
internalized callers

The current implementation of function internalization creats a copy of each
function and replaces every use. This has the downside that the external
versions of the functions will call into the internalized versions of the
functions. This prevents them from being fully independent of eachother. This
patch replaces the current internalization scheme with a method that creates
all the copies of the functions intended to be internalized first and then
replaces the uses as long as their caller is not already internalized.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D106931

(cherry picked from commit adbaa39dfce7a8361d89b6a3b382fd8f50b94727)

Added: 


Modified: 
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/custom_state_machines.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/IPO/Attributor.h 
b/llvm/include/llvm/Transforms/IPO/Attributor.h
index c93b8adcc8901..c3c12fd237463 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1855,6 +1855,10 @@ struct Attributor {
   ///
   static void createShallowWrapper(Function &F);
 
+  /// Returns true if the function \p F can be internalized. i.e. it has a
+  /// compatible linkage.
+  static bool isInternalizable(Function &F);
+
   /// Make another copy of the function \p F such that the copied version has
   /// internal linkage afterwards and can be analysed. Then we replace all uses
   /// of the original function to the copied one
@@ -1870,6 +1874,22 @@ struct Attributor {
   /// null pointer.
   static Function *internalizeFunction(Function &F, bool Force = false);
 
+  /// Make copies of each function in the set \p FnSet such that the copied
+  /// version has internal linkage afterwards and can be analysed. Then we
+  /// replace all uses of the original function to the copied one. The map
+  /// \p FnMap contains a mapping of functions to their internalized versions.
+  ///
+  /// Only non-locally linked functions that have `linkonce_odr` or `weak_odr`
+  /// linkage can be internalized because these linkages guarantee that other
+  /// definitions with the same name have the same semantics as this one.
+  ///
+  /// This version will internalize all the functions in the set \p FnSet at
+  /// once and then replace the uses. This prevents internalized functions 
being
+  /// called by external functions when there is an internalized version in the
+  /// module.
+  static bool internalizeFunctions(SmallPtrSetImpl &FnSet,
+   DenseMap &FnMap);
+
   /// Return the data layout associated with the anchor scope.
   const DataLayout &getDataLayout() const { return InfoCache.DL; }
 

diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp 
b/llvm/lib/Transforms/IPO/Attributor.cpp
index 762317425026b..5ccd001712eb8 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1925,49 +1925,85 @@ void Attributor::createShallowWrapper(Function &F) {
   NumFnShallowWrappersCreated++;
 }
 
+bool Attributor::isInternalizable(Function &F) {
+  if (F.isDeclaration() || F.hasLocalLinkage() ||
+  GlobalValue::isInterposableLinkage(F.getLinkage()))
+return false;
+  return true;
+}
+
 Function *Attributor::internalizeFunction(Function &F, bool Force) {
   if (!AllowDeepWrapper && !Force)
 return nullptr;
-  if (F.isDeclaration() || F.hasLocalLinkage() ||
-  GlobalValue::isInterposableLinkage(F.getLinkage()))
+  if (!isInternalizable(F))
 return nullptr;
 
-  Module &M = *F.getParent();
-  FunctionType *FnTy = F.getFunctionType();
-
-  // create a copy of the current function
-  Function *Copied = Function::Create(FnTy, F.getLinkage(), 
F.getAddressSpace(),
-  F.getName() + ".internalized");
-  ValueToValueMapTy VMap;
-  auto *NewFArgIt = Copied->arg_begin();
-  for (auto &Arg : F.args()) {
-auto ArgName = Arg.getName();
-NewFArgIt->setName(ArgName);
-VMap[&Arg] = &(*NewFArgIt++);
-  }
-  SmallVector Returns;
+  SmallPtrSet FnSet = {&F};
+  DenseMap InternalizedFns;
+  internalizeFunctions(FnSet, InternalizedFns);
 
-  // Copy the body of the original function to the new one
-  CloneFunctionInto(Copied, &F, VMap, 
CloneFunctionChangeType::LocalChangesOnly,
-Returns);
-
-  // Set the linakage and visibility late as CloneFunctionIn

[llvm-branch-commits] [llvm] fd5ec45 - [Attributor] Don't test internalization in the CGSCC pass.

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Joseph Huber
Date: 2021-08-04T16:35:08-07:00
New Revision: fd5ec459c3f9dba0e6781ac11695540b0383179b

URL: 
https://github.com/llvm/llvm-project/commit/fd5ec459c3f9dba0e6781ac11695540b0383179b
DIFF: 
https://github.com/llvm/llvm-project/commit/fd5ec459c3f9dba0e6781ac11695540b0383179b.diff

LOG: [Attributor] Don't test internalization in the CGSCC pass.

Summary:
Enabling internalization in the Attributor's CGSCC pass does something
different that we don't expect. Ignore this for now to pass the tests.

(cherry picked from commit 97851a08e2684388dec24fbe46818704052f9dbe)

Added: 


Modified: 
llvm/test/Transforms/Attributor/internalize.ll

Removed: 




diff  --git a/llvm/test/Transforms/Attributor/internalize.ll 
b/llvm/test/Transforms/Attributor/internalize.ll
index 651c841622a93..3b0998cbf8e3d 100644
--- a/llvm/test/Transforms/Attributor/internalize.ll
+++ b/llvm/test/Transforms/Attributor/internalize.ll
@@ -3,15 +3,11 @@
 
 ; RUN: opt -attributor -attributor-manifest-internal  
-attributor-max-iterations-verify -attributor-annotate-decl-cs 
-attributor-max-iterations=1 -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT,ISOPM,IS__TUNIT_OPM,CHECK_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_TUNIT_NPM_DISABLED,IS__TUNIT_DISABLED,ISOPM_DISABLED,IS__TUNIT_OPM_DISABLED
 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor 
-attributor-manifest-internal  -attributor-max-iterations-verify 
-attributor-annotate-decl-cs -attributor-max-iterations=1  -S < %s | FileCheck 
%s 
--check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT,ISNPM,IS__TUNIT_NPM,CHECK_DISABLED,NOT_CGSCC_OPM_DISABLED,NOT_CGSCC_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,IS__TUNIT_DISABLED,ISNPM_DISABLED,IS__TUNIT_NPM_DISABLED
-; RUN: opt -attributor-cgscc -attributor-manifest-internal  
-attributor-annotate-decl-cs -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC,ISOPM,IS__CGSCC_OPM,CHECK_DISABLED,NOT_TUNIT_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,NOT_CGSCC_NPM_DISABLED,IS__CGSCC_DISABLED,ISOPM_DISABLED,IS__CGSCC_OPM_DISABLED
-; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc 
-attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck 
%s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC,ISNPM,IS__CGSCC_NPM,CHECK_DISABLED,NOT_TUNIT_NPM_DISABLED,NOT_TUNIT_OPM_DISABLED,NOT_CGSCC_OPM_DISABLED,IS__CGSCC_DISABLED,ISNPM_DISABLED,IS__CGSCC_NPM_DISABLED
 
 ; Deep Wrapper enabled
 
 ; RUN: opt -attributor -attributor-manifest-internal  
-attributor-max-iterations-verify -attributor-annotate-decl-cs 
-attributor-max-iterations=11 -attributor-allow-deep-wrappers -disable-inlining 
-S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT,ISOPM,IS__TUNIT_OPM,CHECK_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_TUNIT_NPM_ENABLED,IS__TUNIT_ENABLED,ISOPM_ENABLED,IS__TUNIT_OPM_ENABLED
 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor 
-attributor-manifest-internal  -attributor-max-iterations-verify 
-attributor-annotate-decl-cs -attributor-max-iterations=11 
-attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT,ISNPM,IS__TUNIT_NPM,CHECK_ENABLED,NOT_CGSCC_OPM_ENABLED,NOT_CGSCC_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,IS__TUNIT_ENABLED,ISNPM_ENABLED,IS__TUNIT_NPM_ENABLED
-; RUN: opt -attributor-cgscc -attributor-manifest-internal  
-attributor-annotate-decl-cs -attributor-allow-deep-wrappers -disable-inlining 
-S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC,ISOPM,IS__CGSCC_OPM,CHECK_ENABLED,NOT_TUNIT_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,NOT_CGSCC_NPM_ENABLED,IS__CGSCC_ENABLED,ISOPM_ENABLED,IS__CGSCC_OPM_ENABLED
-; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc 
-attributor-manifest-internal  -attributor-annotate-decl-cs 
-attributor-allow-deep-wrappers -disable-inlining -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC,ISNPM,IS__CGSCC_NPM,CHECK_ENABLED,NOT_TUNIT_NPM_ENABLED,NOT_TUNIT_OPM_ENABLED,NOT_CGSCC_OPM_ENABLED,IS__CGSCC_ENABLED,ISNPM_ENABLED,IS__CGSCC_NPM_ENABLED
 
 ; TEST 1: This function is of linkage `linkonce`, we cannot internalize this
 ; function and use information derived from it
@@ -135,16 +131,15 @@ define void @unused_arg_caller() {
 ; CHECK_DISABLED-NEXT:call void @unused_arg(i8 noundef 0)
 ; CHECK_DISABLED-NEXT:ret void
 ;
-; IS__TUNIT_ENABLED: Function Attrs: nofree noreturn nosync nounwind 
readnone willreturn
-; IS__TUNIT

[llvm-branch-commits] [llvm] b4c29a7 - [SROA] prevent crash on large memset length (PR50910)

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Sanjay Patel
Date: 2021-08-04T16:51:23-07:00
New Revision: b4c29a722b6f3ea342646a726f0faa424f27e09a

URL: 
https://github.com/llvm/llvm-project/commit/b4c29a722b6f3ea342646a726f0faa424f27e09a
DIFF: 
https://github.com/llvm/llvm-project/commit/b4c29a722b6f3ea342646a726f0faa424f27e09a.diff

LOG: [SROA] prevent crash on large memset length (PR50910)

I don't know much about this pass, but we need a stronger
check on the memset length arg to avoid an assert. The
current code was added with D59000.
The test is reduced from:
https://llvm.org/PR50910

Differential Revision: https://reviews.llvm.org/D106462

(cherry picked from commit f2a322bfcfbc62b5523f32c4eded6faf2cad2e24)

Added: 


Modified: 
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/test/Transforms/SROA/slice-width.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index 5ec01454e5b2f..fe160d5415bd2 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -2811,10 +2811,11 @@ class llvm::sroa::AllocaSliceRewriter
   if (BeginOffset > NewAllocaBeginOffset ||
   EndOffset < NewAllocaEndOffset)
 return false;
+  // Length must be in range for FixedVectorType.
   auto *C = cast(II.getLength());
-  if (C->getBitWidth() > 64)
+  const uint64_t Len = C->getLimitedValue();
+  if (Len > std::numeric_limits::max())
 return false;
-  const auto Len = C->getZExtValue();
   auto *Int8Ty = IntegerType::getInt8Ty(NewAI.getContext());
   auto *SrcTy = FixedVectorType::get(Int8Ty, Len);
   return canConvertValue(DL, SrcTy, AllocaTy) &&

diff  --git a/llvm/test/Transforms/SROA/slice-width.ll 
b/llvm/test/Transforms/SROA/slice-width.ll
index a801de68217ff..b15e66b462c0f 100644
--- a/llvm/test/Transforms/SROA/slice-width.ll
+++ b/llvm/test/Transforms/SROA/slice-width.ll
@@ -145,3 +145,16 @@ define void @PR50888() {
   call void @llvm.memset.p0i8.i64(i8* align 16 %array, i8 0, i64 ptrtoint 
(void ()* @PR50888 to i64), i1 false)
   ret void
 }
+
+; Don't crash on out-of-bounds length.
+
+define void @PR50910() {
+; CHECK-LABEL: @PR50910(
+; CHECK-NEXT:[[T1:%.*]] = alloca i8, i64 1, align 8
+; CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 8 [[T1]], i8 0, i64 
1, i1 false)
+; CHECK-NEXT:ret void
+;
+  %t1 = alloca i8, i64 1, align 8
+  call void @llvm.memset.p0i8.i64(i8* align 8 %t1, i8 0, i64 4294967296, i1 
false)
+  ret void
+}



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 906eada - Revert "Revert of D49126 [PredicateInfo] Use custom mangling to support ssa_copy with unnamed types."

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Jeroen Dobbelaere
Date: 2021-08-04T16:51:29-07:00
New Revision: 906eada08ec23e383c850c490982b9c9a7b79a3a

URL: 
https://github.com/llvm/llvm-project/commit/906eada08ec23e383c850c490982b9c9a7b79a3a
DIFF: 
https://github.com/llvm/llvm-project/commit/906eada08ec23e383c850c490982b9c9a7b79a3a.diff

LOG: Revert "Revert of D49126 [PredicateInfo] Use custom mangling to support 
ssa_copy with unnamed types."

This reverts commit 77080a1eb6061df2dcfae8ac84b85ad4d1e02031.

This change introduced issues detected with EXPENSIVE_CHECKS. Reverting to 
restore the
needed function cleanup. A next patch will then just improve on the name 
mangling.

(cherry picked from commit dc5570d149ca6a0931413bf1ad469eb8f9517f82)

Added: 


Modified: 
llvm/include/llvm/Transforms/Utils/PredicateInfo.h
llvm/lib/Transforms/Utils/PredicateInfo.cpp
llvm/test/Other/debugcounter-predicateinfo.ll
llvm/test/Transforms/Util/PredicateInfo/condprop.ll
llvm/test/Transforms/Util/PredicateInfo/diamond.ll
llvm/test/Transforms/Util/PredicateInfo/edge.ll
llvm/test/Transforms/Util/PredicateInfo/testandor.ll
llvm/test/Transforms/Util/PredicateInfo/unnamed-types.ll

Removed: 




diff  --git a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h 
b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
index c4030735d9657..c922476ac79da 100644
--- a/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
+++ b/llvm/include/llvm/Transforms/Utils/PredicateInfo.h
@@ -51,11 +51,13 @@
 #define LLVM_TRANSFORMS_UTILS_PREDICATEINFO_H
 
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/ilist.h"
 #include "llvm/ADT/ilist_node.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Value.h"
+#include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
 
 namespace llvm {
@@ -176,7 +178,7 @@ class PredicateSwitch : public PredicateWithEdge {
 class PredicateInfo {
 public:
   PredicateInfo(Function &, DominatorTree &, AssumptionCache &);
-  ~PredicateInfo() = default;
+  ~PredicateInfo();
 
   void verifyPredicateInfo() const;
 
@@ -203,6 +205,8 @@ class PredicateInfo {
   // the Predicate Info, they belong to the ValueInfo structs in the ValueInfos
   // vector.
   DenseMap PredicateMap;
+  // The set of ssa_copy declarations we created with our custom mangling.
+  SmallSet, 20> CreatedDeclarations;
 };
 
 // This pass does eager building and then printing of PredicateInfo. It is used

diff  --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp 
b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 91280762aaa7d..4c262f60014ce 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Analysis/AssumptionCache.h"
 #include "llvm/Analysis/CFG.h"
 #include "llvm/IR/AssemblyAnnotationWriter.h"
@@ -23,6 +24,7 @@
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Metadata.h"
@@ -537,6 +539,21 @@ void PredicateInfoBuilder::buildPredicateInfo() {
   renameUses(OpsToRename);
 }
 
+// Create a ssa_copy declaration with custom mangling, because
+// Intrinsic::getDeclaration does not handle overloaded unnamed types properly:
+// all unnamed types get mangled to the same string. We use the pointer
+// to the type as name here, as it guarantees unique names for 
diff erent
+// types and we remove the declarations when destroying PredicateInfo.
+// It is a workaround for PR38117, because solving it in a fully general way is
+// tricky (FIXME).
+static Function *getCopyDeclaration(Module *M, Type *Ty) {
+  std::string Name = "llvm.ssa.copy." + utostr((uintptr_t) Ty);
+  return cast(
+  M->getOrInsertFunction(Name,
+ getType(M->getContext(), Intrinsic::ssa_copy, Ty))
+  .getCallee());
+}
+
 // Given the renaming stack, make all the operands currently on the stack real
 // by inserting them into the IR.  Return the last operation's value.
 Value *PredicateInfoBuilder::materializeStack(unsigned int &Counter,
@@ -568,8 +585,9 @@ Value *PredicateInfoBuilder::materializeStack(unsigned int 
&Counter,
 // order in the case of multiple predicateinfo in the same block.
 if (isa(ValInfo)) {
   IRBuilder<> B(getBranchTerminator(ValInfo));
-  Function *IF = Intrinsic::getDeclaration(
-  F.getParent(), Intrinsic::ssa_copy, Op->getType());
+  Function *IF = getCopyDeclaration(F.getParent(), Op->getType());
+  if (IF->users().empty())
+PI.CreatedDeclarations.insert(IF);
   CallInst *PIC =
   B.CreateCall(IF, Op, Op->getName() + "." + Twine(Counte

[llvm-branch-commits] [llvm] 36eb72e - [PredicateInfo] Use Intrinsic::getDeclaration now that it handles unnamed types.

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Jeroen Dobbelaere
Date: 2021-08-04T16:51:33-07:00
New Revision: 36eb72ec614ae2da0943e03b50374364f24883b2

URL: 
https://github.com/llvm/llvm-project/commit/36eb72ec614ae2da0943e03b50374364f24883b2
DIFF: 
https://github.com/llvm/llvm-project/commit/36eb72ec614ae2da0943e03b50374364f24883b2.diff

LOG: [PredicateInfo] Use Intrinsic::getDeclaration now that it handles unnamed 
types.

This is a second attempt to fix the EXPENSIVE_CHECKS issue that was mentioned  
In D91661#2875179 by @jroelofs.

(The first attempt was in D105983)

D91661 more or less completely reverted D49126 and by doing so also removed the 
cleanup logic of the created declarations and calls.
This patch is a replacement for D91661 (which must itself be reverted first). 
It replaces the custom declaration creation with the
generic version and shows the test impact. It also tracks the number of 
NamedValues to detect if a new prototype was added instead
of looking at the available users of a prototype.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D106147

(cherry picked from commit 03b8c69d06f810f13d0b74d06dabea37c43e5b78)

Added: 


Modified: 
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
llvm/lib/Transforms/Utils/PredicateInfo.cpp
llvm/test/Other/debugcounter-predicateinfo.ll
llvm/test/Transforms/Util/PredicateInfo/condprop.ll
llvm/test/Transforms/Util/PredicateInfo/diamond.ll
llvm/test/Transforms/Util/PredicateInfo/edge.ll
llvm/test/Transforms/Util/PredicateInfo/testandor.ll
llvm/test/Transforms/Util/PredicateInfo/unnamed-types.ll

Removed: 




diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 81e29d9b86e88..97aea5aedf221 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -324,6 +324,9 @@ class Module {
   /// name is not found.
   GlobalValue *getNamedValue(StringRef Name) const;
 
+  /// Return the number of global values in the module.
+  unsigned getNumNamedValues() const;
+
   /// Return a unique non-zero ID for the specified metadata kind. This ID is
   /// uniqued across modules in the current LLVMContext.
   unsigned getMDKindID(StringRef Name) const;

diff  --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 7c18dc0ed299f..63ea41fba89ab 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -114,6 +114,10 @@ GlobalValue *Module::getNamedValue(StringRef Name) const {
   return cast_or_null(getValueSymbolTable().lookup(Name));
 }
 
+unsigned Module::getNumNamedValues() const {
+  return getValueSymbolTable().size();
+}
+
 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
 /// This ID is uniqued across modules in the current LLVMContext.
 unsigned Module::getMDKindID(StringRef Name) const {

diff  --git a/llvm/lib/Transforms/Utils/PredicateInfo.cpp 
b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
index 4c262f60014ce..bd2b6fafdf2eb 100644
--- a/llvm/lib/Transforms/Utils/PredicateInfo.cpp
+++ b/llvm/lib/Transforms/Utils/PredicateInfo.cpp
@@ -539,21 +539,6 @@ void PredicateInfoBuilder::buildPredicateInfo() {
   renameUses(OpsToRename);
 }
 
-// Create a ssa_copy declaration with custom mangling, because
-// Intrinsic::getDeclaration does not handle overloaded unnamed types properly:
-// all unnamed types get mangled to the same string. We use the pointer
-// to the type as name here, as it guarantees unique names for 
diff erent
-// types and we remove the declarations when destroying PredicateInfo.
-// It is a workaround for PR38117, because solving it in a fully general way is
-// tricky (FIXME).
-static Function *getCopyDeclaration(Module *M, Type *Ty) {
-  std::string Name = "llvm.ssa.copy." + utostr((uintptr_t) Ty);
-  return cast(
-  M->getOrInsertFunction(Name,
- getType(M->getContext(), Intrinsic::ssa_copy, Ty))
-  .getCallee());
-}
-
 // Given the renaming stack, make all the operands currently on the stack real
 // by inserting them into the IR.  Return the last operation's value.
 Value *PredicateInfoBuilder::materializeStack(unsigned int &Counter,
@@ -583,10 +568,17 @@ Value *PredicateInfoBuilder::materializeStack(unsigned 
int &Counter,
 // to ensure we dominate all of our uses.  Always insert right before the
 // relevant instruction (terminator, assume), so that we insert in proper
 // order in the case of multiple predicateinfo in the same block.
+// The number of named values is used to detect if a new declaration was
+// added. If so, that declaration is tracked so that it can be removed when
+// the analysis is done. The corner case were a new declaration results in
+// a name clash and the old name being renamed is not considered as that
+// represents an invalid module.
 if (isa(ValInfo)) {
   IRBuilder<> B(getBranchTerminator(ValInfo));
-  Function *IF = get

[llvm-branch-commits] [llvm] f4b8a74 - Fixing an infinite loop problem in InstCombine

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Andy Kaylor
Date: 2021-08-04T16:51:40-07:00
New Revision: f4b8a74d8e6f210a09cce59a6f7ab3bd605fd6f1

URL: 
https://github.com/llvm/llvm-project/commit/f4b8a74d8e6f210a09cce59a6f7ab3bd605fd6f1
DIFF: 
https://github.com/llvm/llvm-project/commit/f4b8a74d8e6f210a09cce59a6f7ab3bd605fd6f1.diff

LOG: Fixing an infinite loop problem in InstCombine

Patch by Mohammad Fawaz

This issues started happening after
https://github.com/llvm/llvm-project/commit/b373b5990d5991a920c421b21a352e4ccf4c4993
Basically, if the memcpy is volatile, the collectUsers() function should
return false, just like we do for volatile loads.

Differential Revision: https://reviews.llvm.org/D106950

(cherry picked from commit b4d945bacdaf2c60dd5fdb119b90cced73c41beb)

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/memcpy-from-global.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index a8474e27383de..80abc775299a5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -261,8 +261,8 @@ class PointerReplacer {
 
 bool PointerReplacer::collectUsers(Instruction &I) {
   for (auto U : I.users()) {
-Instruction *Inst = cast(&*U);
-if (LoadInst *Load = dyn_cast(Inst)) {
+auto *Inst = cast(&*U);
+if (auto *Load = dyn_cast(Inst)) {
   if (Load->isVolatile())
 return false;
   Worklist.insert(Load);
@@ -270,7 +270,9 @@ bool PointerReplacer::collectUsers(Instruction &I) {
   Worklist.insert(Inst);
   if (!collectUsers(*Inst))
 return false;
-} else if (isa(Inst)) {
+} else if (auto *MI = dyn_cast(Inst)) {
+  if (MI->isVolatile())
+return false;
   Worklist.insert(Inst);
 } else if (Inst->isLifetimeStartOrEnd()) {
   continue;

diff  --git a/llvm/test/Transforms/InstCombine/memcpy-from-global.ll 
b/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
index e5f197f94dab5..7fe49f56f8dd3 100644
--- a/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
+++ b/llvm/test/Transforms/InstCombine/memcpy-from-global.ll
@@ -342,4 +342,22 @@ entry:
   ret float %r
 }
 
+; If the memcpy is volatile, it should not be removed
+define float @test11_volatile(i64 %i) {
+; CHECK-LABEL: @test11_volatile(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: alloca
+; CHECK: call void @llvm.lifetime.start.p0i8
+; CHECK: call void @llvm.memcpy
+
+entry:
+  %a = alloca [4 x float], align 4
+  %b = bitcast [4 x float]* %a to i8*
+  call void @llvm.lifetime.start.p0i8(i64 16, i8* %b)
+  call void @llvm.memcpy.p0i8.p1i8.i64(i8* align 4 %b, i8 addrspace(1)* align 
4 bitcast ([4 x float] addrspace(1)* @I to i8 addrspace(1)*), i64 16, i1 true)
+  %g = getelementptr inbounds [4 x float], [4 x float]* %a, i64 0, i64 %i
+  %r = load float, float* %g, align 4
+  ret float %r
+}
+
 attributes #0 = { null_pointer_is_valid }



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 93da37d - [test] Fix tools/gold/X86/comdat-nodeduplicate.ll on non-X86 hosts

2021-08-04 Thread Fangrui Song via llvm-branch-commits

Author: Nathan Chancellor
Date: 2021-08-04T19:43:41-07:00
New Revision: 93da37dc58e9d1d4a685bcb6a30a9d3ff78733f9

URL: 
https://github.com/llvm/llvm-project/commit/93da37dc58e9d1d4a685bcb6a30a9d3ff78733f9
DIFF: 
https://github.com/llvm/llvm-project/commit/93da37dc58e9d1d4a685bcb6a30a9d3ff78733f9.diff

LOG: [test] Fix tools/gold/X86/comdat-nodeduplicate.ll on non-X86 hosts

When running this test on an aarch64 machine, it fails:

```
/usr/bin/ld.gold: error: 
.../test/tools/gold/X86/Output/comdat-nodeduplicate.ll.tmp/ab.lto.o: 
incompatible target
```

Specify the elf_x86_64 emulation as all of the other gold plugin tests
do.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D107020

(cherry picked from commit 5060224d9eed8b8359ed5090bb7c577b8575e9e7)

Added: 


Modified: 
llvm/test/tools/gold/X86/comdat-nodeduplicate.ll

Removed: 




diff  --git a/llvm/test/tools/gold/X86/comdat-nodeduplicate.ll 
b/llvm/test/tools/gold/X86/comdat-nodeduplicate.ll
index 11d04d2aab1f..c27d91a1d437 100644
--- a/llvm/test/tools/gold/X86/comdat-nodeduplicate.ll
+++ b/llvm/test/tools/gold/X86/comdat-nodeduplicate.ll
@@ -8,7 +8,7 @@
 ; RUN: llvm-as %t/b.ll -o %t/b.bc
 ; RUN: llvm-as %t/c.ll -o %t/c.bc
 
-; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext --plugin-opt=save-temps \
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext 
--plugin-opt=save-temps \
 ; RUN:   -u foo %t/a.bc --start-lib %t/b.bc --end-lib -o %t/ab
 
 ; RUN: FileCheck %s --check-prefix=RESOL_AB < %t/ab.resolution.txt
@@ -20,7 +20,7 @@
 ; DATA: 0x[[#%x,]] 0100   
 
 ;; __profc_foo from c.bc is non-prevailing and thus discarded.
-; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext --plugin-opt=save-temps \
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext 
--plugin-opt=save-temps \
 ; RUN:   -u foo -u c %t/a.bc --start-lib %t/b.bc %t/c.bc --end-lib -o %t/abc
 ; RUN: FileCheck %s --check-prefix=RESOL_ABC < %t/abc.resolution.txt
 ; RUN: llvm-readelf -x .data %t/abc | FileCheck %s --check-prefix=DATA
@@ -35,7 +35,7 @@
 ; RUN: opt --module-summary %t/b.ll -o %t/b.bc
 ; RUN: opt --module-summary %t/c.ll -o %t/c.bc
 
-; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
 ; RUN:   -u foo %t/a.bc --start-lib %t/b.bc %t/c.bc --end-lib -o %t/abc
 ; RUN: llvm-readelf -x .data %t/abc | FileCheck %s --check-prefix=DATA
 



___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 1f35d7c - [ConstantFold] Get rid of special cases for sizeof etc.

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Eli Friedman
Date: 2021-08-04T21:25:15-07:00
New Revision: 1f35d7c48278c71f9f8554c7962b04a3affcfd33

URL: 
https://github.com/llvm/llvm-project/commit/1f35d7c48278c71f9f8554c7962b04a3affcfd33
DIFF: 
https://github.com/llvm/llvm-project/commit/1f35d7c48278c71f9f8554c7962b04a3affcfd33.diff

LOG: [ConstantFold] Get rid of special cases for sizeof etc.

Target-dependent constant folding will fold these down to simple
constants (or at least, expressions that don't involve a GEP).  We don't
need heroics to try to optimize the form of the expression before that
happens.

Fixes https://bugs.llvm.org/show_bug.cgi?id=51232 .

Differential Revision: https://reviews.llvm.org/D107116

(cherry picked from commit 2a2847823f0d13188c43ebdd0baf42a95df750c7)

Added: 


Modified: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp
clang/test/OpenMP/for_reduction_codegen.cpp
clang/test/OpenMP/master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_reduction_codegen.cpp
clang/test/OpenMP/parallel_master_taskloop_simd_reduction_codegen.cpp
clang/test/OpenMP/taskloop_reduction_codegen.cpp
clang/test/OpenMP/taskloop_simd_reduction_codegen.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Other/constant-fold-gep.ll
llvm/test/Transforms/LowerTypeTests/function-disjoint.ll
llvm/test/tools/llvm-as/slow-ptrtoint.ll

Removed: 




diff  --git 
a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
index a079b2898bc8..636d33344699 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.c
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -x c   -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
 // RUN: %clang_cc1 -x c   -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s
 
@@ -14,19 +15,19 @@ struct S {
   int x, y;
 };
 
-// CHECK-LABEL: define{{.*}} i64 @{{.*}}get_offset_of_y_naively{{.*}}(
+// CHECK-LABEL: @get_offset_of_y_naively(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i64 ptrtoint (i32* getelementptr inbounds 
([[STRUCT_S:%.*]], %struct.S* null, i32 0, i32 1) to i64)
+//
 uintptr_t get_offset_of_y_naively() {
-  // CHECK: [[ENTRY:.*]]:
-  // CHECK-NEXT:   ret i64 ptrtoint (i32* getelementptr (i32, i32* null, i32 
1) to i64)
-  // CHECK-NEXT: }
   return ((uintptr_t)(&(((struct S *)0)->y)));
 }
 
-// CHECK-LABEL: define{{.*}} i64 @{{.*}}get_offset_of_y_via_builtin{{.*}}(
+// CHECK-LABEL: @get_offset_of_y_via_builtin(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:ret i64 4
+//
 uintptr_t get_offset_of_y_via_builtin() {
-  // CHECK: [[ENTRY:.*]]:
-  // CHECK-NEXT:   ret i64 4
-  // CHECK-NEXT: }
   return __builtin_offsetof(struct S, y);
 }
 

diff  --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index e30e1efd2bbe..233a1fa8797c 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -232,7 +232,7 @@ char *nullptr_allones_BAD() {
   // CHECK-SANITIZE-C-NEXT: br i1 false, label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 mul (i64 ptrtoint 
(i8* getelementptr (i8, i8* null, i32 1) to i64), i64 -1), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
-  // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) 
to i64), i64 -1))
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) 
to i64))
   // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to 
i64), i64 -1))
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 
19){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize

diff  --git 
a/clang/test/CodeGenCXX/catch-nullptr-and-nonzero-offset-in-offsetof-idiom.cpp 

[llvm-branch-commits] [mlir] 0661286 - Fix a couple regression tests I missed updating in 2a284782

2021-08-04 Thread Tom Stellard via llvm-branch-commits

Author: Eli Friedman
Date: 2021-08-04T21:25:15-07:00
New Revision: 0661286a55fb7ef978bd5193fe140191cf7ac445

URL: 
https://github.com/llvm/llvm-project/commit/0661286a55fb7ef978bd5193fe140191cf7ac445
DIFF: 
https://github.com/llvm/llvm-project/commit/0661286a55fb7ef978bd5193fe140191cf7ac445.diff

LOG: Fix a couple regression tests I missed updating in 2a284782

(cherry picked from commit 6eb2ffbaeb56c8b08ad17c823e1699b964e10b8b)

Added: 


Modified: 
clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
mlir/test/Target/LLVMIR/openacc-llvm.mlir

Removed: 




diff  --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index 233a1fa8797c..5c233a6ce264 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -230,10 +230,10 @@ char *nullptr_allones_BAD() {
   // CHECK:   define{{.*}} i8* @nullptr_allones_BAD()
   // CHECK-NEXT:  [[ENTRY:.*]]:
   // CHECK-SANITIZE-C-NEXT: br i1 false, label %[[CONT:.*]], label 
%[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
-  // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 mul (i64 ptrtoint 
(i8* getelementptr (i8, i8* null, i32 1) to i64), i64 -1), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE-CPP-NEXT:   br i1 icmp eq (i64 ptrtoint (i8* 
getelementptr inbounds (i8, i8* null, i64 -1) to i64), i64 0), label 
%[[CONT:.*]], label %[[HANDLER_POINTER_OVERFLOW:[^,]+]],{{.*}} !nosanitize
   // CHECK-SANITIZE:  [[HANDLER_POINTER_OVERFLOW]]:
   // CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_pointer_overflow_abort(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] 
to i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) 
to i64))
-  // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 mul (i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to 
i64), i64 -1))
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_pointer_overflow(i8* bitcast ({ {{{.*}}} }* @[[LINE_800]] to 
i8*), i64 0, i64 ptrtoint (i8* getelementptr inbounds (i8, i8* null, i64 -1) to 
i64))
   // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.ubsantrap(i8 
19){{.*}}, !nosanitize
   // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
   // CHECK-SANITIZE:  [[CONT]]:

diff  --git a/mlir/test/Target/LLVMIR/openacc-llvm.mlir 
b/mlir/test/Target/LLVMIR/openacc-llvm.mlir
index f0fb7ff82c9b..867213d15276 100644
--- a/mlir/test/Target/LLVMIR/openacc-llvm.mlir
+++ b/mlir/test/Target/LLVMIR/openacc-llvm.mlir
@@ -54,7 +54,7 @@ llvm.func @testenterdataop(%arg0: !llvm.ptr, %arg1: 
!llvm.ptr, %arg2:
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float** null, i32 
1) to i64), i64* [[SIZEGEP]], align 4
 
 // CHECK: [[ARGBASE_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARGBASE_ALLOCA]], i32 0, i32 0
 // CHECK: [[ARG_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARG_ALLOCA]], i32 0, i32 0
@@ -114,7 +114,7 @@ llvm.func @testexitdataop(%arg0: !llvm.struct<(ptr, 
ptr, i64, array<1
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float** null, i32 
1) to i64), i64* [[SIZEGEP]], align 4
 
 // CHECK: [[ARGBASE_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARGBASE_ALLOCA]], i32 0, i32 0
 // CHECK: [[ARG_ALLOCA_GEP:%.*]] = getelementptr inbounds [2 x i8*], [2 x 
i8*]* [[ARG_ALLOCA]], i32 0, i32 0
@@ -173,7 +173,7 @@ llvm.func @testupdateop(%arg0: !llvm.struct<(ptr, 
ptr, i64, array<1 x
 // CHECK: [[ARGGEPCAST:%.*]] = bitcast i8** [[ARGGEP]] to float**
 // CHECK: store float* [[SIMPLEPTR]], float** [[ARGGEPCAST]], align 8
 // CHECK: [[SIZEGEP:%.*]] = getelementptr inbounds [2 x i64], [2 x i64]* 
[[SIZE_ALLOCA]], i32 0, i32 1
-// CHECK: store i64 ptrtoint (i1** getelementptr (i1*, i1** null, i32 1) to 
i64), i64* [[SIZEGEP]], align 4
+// CHECK: store i64 ptrtoint (float** getelementptr (float*, float**