[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis updated 
https://github.com/llvm/llvm-project/pull/98162

>From f209cca87cf7c53242a353a505e3bfe34688a1b2 Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis 
Date: Tue, 9 Jul 2024 08:52:51 +0100
Subject: [PATCH 1/2] [BOLT] Added more details on heatmap docs.

---
 bolt/docs/Heatmaps.md | 53 +++
 1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/bolt/docs/Heatmaps.md b/bolt/docs/Heatmaps.md
index e1b59d49ad102..c1a01839d6682 100644
--- a/bolt/docs/Heatmaps.md
+++ b/bolt/docs/Heatmaps.md
@@ -1,9 +1,9 @@
 # Code Heatmaps
 
 BOLT has gained the ability to print code heatmaps based on
-sampling-based LBR profiles generated by `perf`. The output is produced
-in colored ASCII to be displayed in a color-capable terminal. It looks
-something like this:
+sampling-based profiles generated by `perf`, either with `LBR` data or not.
+The output is produced in colored ASCII to be displayed in a color-capable
+terminal. It looks something like this:
 
 ![](./Heatmap.png)
 
@@ -32,17 +32,7 @@ $ llvm-bolt-heatmap -p perf.data 
 ```
 
 By default the heatmap will be dumped to *stdout*. You can change it
-with `-o ` option. Each character/block in the heatmap
-shows the execution data accumulated for corresponding 64 bytes of
-code. You can change this granularity with a `-block-size` option.
-E.g. set it to 4096 to see code usage grouped by 4K pages.
-Other useful options are:
-
-```bash
--line-size=   - number of entries per line (default 256)
--max-address= - maximum address considered valid for heatmap (default 
4GB)
--print-mappings= - print mappings in legend, between characters/blocks 
and text sections (default false)
-```
+with `-o ` option.
 
 If you prefer to look at the data in a browser (or would like to share
 it that way), then you can use an HTML conversion tool. E.g.:
@@ -50,3 +40,38 @@ it that way), then you can use an HTML conversion tool. E.g.:
 ```bash
 $ aha -b -f  > .html
 ```
+
+---
+
+## Background on heatmaps:
+A heatmap is effectively a histogram that is rendered into a grid for better
+visualization.
+In theory we can generate a heatmap using any binary and a perf profile.
+
+Each block/character in the heatmap shows the execution data accumulated for
+corresponding 64 bytes of code. You can change this granularity with a
+`-block-size` option.
+E.g. set it to 4096 to see code usage grouped by 4K pages.
+
+
+When a block is shown as a dot, it means that no samples were found for that 
address.
+When it is shown as a letter, it indicates a captured sample on a particular 
text section of the binary. To show a mapping between letters and text sections 
in the legend, use `-print-mappings`. When a sampled address does not belong to 
any of the TextSegments, the characters 'o' or 'O' will be shown.
+
+The legend shows by default the ranges in the heatmap according to the number
+of samples per block.
+A color is assigned per range, except the first two ranges that distinguished 
by
+lower and upper case letters.
+
+Each consecutive line in the heatmap advances by the same amount,
+with the binary size covered by a line being dependent on the block size and 
the
+line size.
+An empty new line is inserted for bigger gaps between samples.
+
+
+Some useful options are:
+
+```
+-line-size=   - number of entries per line (default 256)
+-max-address= - maximum address considered valid for heatmap (default 
4GB)
+-print-mappings - print mappings in the legend, between characters/blocks 
and text sections (default false)
+```

>From 3c7b4df7bc9c5e0af1aba3d6fa95a91b98fca40b Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis 
Date: Thu, 11 Jul 2024 09:05:35 +0100
Subject: [PATCH 2/2] Added explanation for x axis.

---
 bolt/docs/HeatmapHeader.png | Bin 0 -> 76799 bytes
 bolt/docs/Heatmaps.md   |  29 +++--
 2 files changed, 23 insertions(+), 6 deletions(-)
 create mode 100644 bolt/docs/HeatmapHeader.png

diff --git a/bolt/docs/HeatmapHeader.png b/bolt/docs/HeatmapHeader.png
new file mode 100644
index 
..a519dc6215d8cf844f78a7592760cc30738b1a14
GIT binary patch
literal 76799
zcmeFZWl$X5+9-;90)YU*2Z9qkxDD=Z!68_1g1bgY2yVgMEqGwC7%stG5?lux9Om@A
zTkBr-sW1E7Key^oH8V|jueEwTuKi9!P5vGZISvvM(mh2587(9vTofcE;5(pBO`y;JTNA)+NZ>%uHFsMLt5nqrZ
zq9iRoPS5J7j55pRH5MD
zG}hPk#i7nl;XOEf_!l1DZW_TK2ENPd5}bXgn>gRYYz*M
zkCUUbyReTK-CuVI1ILKdoOGbSZt-vsqkE>R0g`rcvj*{VaB*8J371prxv34|&v2y}o2CO0e^eK<%U-$pNuKa7oe;fJiUn6-0xds1y=)Yb1
ze-71kw|0|uaRS!#5dRmx{yzBMFaCX?C?{g;{|1V`!TGPV0HDQjL^=P7G;tj0jN}sl
zkCb*Y>N>zLKxKdZEdbxlzz6XQd@A~$Vyu@VA%T$;Wh8Zckarg_eICkEbROzULEFxv
zL*9c}L3DdWadaRh%&k#>b(B$mDAhv^Z~^Q46GjlqXn|7osK_f98;)jUx7V*;5!Awc
zslV@My@Ihr9e-b=phs41jPp*2j38Tp4pfyF`|fCxU4
zqWm}O<{*W3Rxc-X(LVmuN5%qyL0r|yXiq?~^maJCsgRHY#cW-zA|=kLTL}Hea7OG(
z_i2AKZ#O%rlZEb&W+#B5VWCC)4YSz33Nh*I?^o_iu4YIo7fAS6^Lu&+l_cx(qIcGe
zwC^iauD=c9jZ$_&gN#N1M*5$BnIa>jgqnpiy_1$%_C=rdreV6keOTjidp?5N>~s5p
zUNuYU_xC85>W+Y46+Yfo9B0slhN+

[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis created 
https://github.com/llvm/llvm-project/pull/98448

`createDummyReturnFunction` is not creating a function but instead only a 
function body
that is simply a return statement.

This patch renames it to `createReturnBody`

>From b564185beebcd5d4d18036edfd2f1a76370f3f8f Mon Sep 17 00:00:00 2001
From: Paschalis Mpeis 
Date: Thu, 11 Jul 2024 09:32:12 +0100
Subject: [PATCH] [NFC][BOLT] Rename createDummyReturnFunction to
 createReturnBody

createDummyReturnFunction is not creating a function but instead only
a function body that is simply a return statement. So it is renamed to:
createReturnBody
---
 bolt/include/bolt/Core/MCPlusBuilder.h | 2 +-
 bolt/lib/Passes/Instrumentation.cpp| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h 
b/bolt/include/bolt/Core/MCPlusBuilder.h
index 885d627f7b64f..c20b0edc36499 100644
--- a/bolt/include/bolt/Core/MCPlusBuilder.h
+++ b/bolt/include/bolt/Core/MCPlusBuilder.h
@@ -2044,7 +2044,7 @@ class MCPlusBuilder {
   /// Returns a function body that contains only a return instruction. An
   /// example usage is a workaround for the '__bolt_fini_trampoline' of
   // Instrumentation.
-  virtual InstructionListType createDummyReturnFunction(MCContext *Ctx) const {
+  virtual InstructionListType createReturnBody(MCContext *Ctx) const {
 InstructionListType Insts(1);
 createReturn(Insts[0]);
 return Insts;
diff --git a/bolt/lib/Passes/Instrumentation.cpp 
b/bolt/lib/Passes/Instrumentation.cpp
index e824a42d82696..805e7a7434f8f 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -754,7 +754,7 @@ void 
Instrumentation::createAuxiliaryFunctions(BinaryContext &BC) {
   // with unknown symbol in runtime library. E.g. for static PIE
   // executable
   createSimpleFunction("__bolt_fini_trampoline",
-   BC.MIB->createDummyReturnFunction(BC.Ctx.get()));
+   BC.MIB->createReturnBody(BC.Ctx.get()));
 }
   }
 }

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis edited 
https://github.com/llvm/llvm-project/pull/98448
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis ready_for_review 
https://github.com/llvm/llvm-project/pull/98448
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)


Changes

`createDummyReturnFunction` is not creating a function but instead only a 
function body
that is simply a return statement.

This patch renames it to `createReturnBody`

---

Stacked on top of:
- #96626

---
Full diff: https://github.com/llvm/llvm-project/pull/98448.diff


2 Files Affected:

- (modified) bolt/include/bolt/Core/MCPlusBuilder.h (+1-1) 
- (modified) bolt/lib/Passes/Instrumentation.cpp (+1-1) 


``diff
diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h 
b/bolt/include/bolt/Core/MCPlusBuilder.h
index 885d627f7b64f..c20b0edc36499 100644
--- a/bolt/include/bolt/Core/MCPlusBuilder.h
+++ b/bolt/include/bolt/Core/MCPlusBuilder.h
@@ -2044,7 +2044,7 @@ class MCPlusBuilder {
   /// Returns a function body that contains only a return instruction. An
   /// example usage is a workaround for the '__bolt_fini_trampoline' of
   // Instrumentation.
-  virtual InstructionListType createDummyReturnFunction(MCContext *Ctx) const {
+  virtual InstructionListType createReturnBody(MCContext *Ctx) const {
 InstructionListType Insts(1);
 createReturn(Insts[0]);
 return Insts;
diff --git a/bolt/lib/Passes/Instrumentation.cpp 
b/bolt/lib/Passes/Instrumentation.cpp
index e824a42d82696..805e7a7434f8f 100644
--- a/bolt/lib/Passes/Instrumentation.cpp
+++ b/bolt/lib/Passes/Instrumentation.cpp
@@ -754,7 +754,7 @@ void 
Instrumentation::createAuxiliaryFunctions(BinaryContext &BC) {
   // with unknown symbol in runtime library. E.g. for static PIE
   // executable
   createSimpleFunction("__bolt_fini_trampoline",
-   BC.MIB->createDummyReturnFunction(BC.Ctx.get()));
+   BC.MIB->createReturnBody(BC.Ctx.get()));
 }
   }
 }

``




https://github.com/llvm/llvm-project/pull/98448
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2810,9 +2819,117 @@ LogicalResult WinogradInputTransformOp::verify() {
   if (failed(verifyCompatibleShape(expectedOutputShape, outputShape))) {
 return emitOpError("the output shape is not expected");
   }
+
   return success();
 }
 
+SmallVector
+WinogradInputTransformOp::getIterationDomain(OpBuilder &builder) {
+  Location loc = getLoc();
+  auto indexType = builder.getIndexType();
+  auto zeroAttr = builder.getIntegerAttr(indexType, 0);
+  auto oneAttr = builder.getIntegerAttr(indexType, 1);
+  Value output = getOutput();
+  SmallVector loopBounds(6);
+  for (unsigned dim = 0; dim < 6; ++dim) {
+loopBounds[dim].offset = zeroAttr;
+loopBounds[dim].size = getDimValue(builder, loc, output, dim);
+loopBounds[dim].stride = oneAttr;
+  }
+  return loopBounds;
+}
+
+SmallVector
+WinogradInputTransformOp::getLoopIteratorTypes() {
+  SmallVector iteratorTypes(6,
+ 
utils::IteratorType::parallel);
+  return iteratorTypes;
+}
+
+LogicalResult WinogradInputTransformOp::getResultTilePosition(
+OpBuilder &builder, unsigned resultNumber, ArrayRef offsets,
+ArrayRef sizes, SmallVector &resultOffsets,
+SmallVector &resultSizes) {
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  auto oneAttr = builder.getI64IntegerAttr(1);
+
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(offsets[2]);
+  resultOffsets.push_back(offsets[3]);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultSizes.push_back(sizes[0]);
+  resultSizes.push_back(sizes[1]);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(sizes[4]);
+  resultSizes.push_back(sizes[5]);
+
+  return success();
+}
+
+FailureOr
+WinogradInputTransformOp::getTiledImplementation(OpBuilder &builder,
+ ArrayRef 
offsets,
+ ArrayRef sizes) 
{
+  auto oneAttr = builder.getI64IntegerAttr(1);
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  Value input = getInput();
+  auto inputType = cast(input.getType());
+  auto inputShape = inputType.getShape();

ftynse wrote:

Please expand `auto` unless the type is obvious from statement-level context 
(builders on the RHS are fine, but I don't remember what `getShape` returns as 
a type).

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2810,9 +2819,117 @@ LogicalResult WinogradInputTransformOp::verify() {
   if (failed(verifyCompatibleShape(expectedOutputShape, outputShape))) {
 return emitOpError("the output shape is not expected");
   }
+
   return success();
 }
 
+SmallVector
+WinogradInputTransformOp::getIterationDomain(OpBuilder &builder) {
+  Location loc = getLoc();
+  auto indexType = builder.getIndexType();
+  auto zeroAttr = builder.getIntegerAttr(indexType, 0);
+  auto oneAttr = builder.getIntegerAttr(indexType, 1);
+  Value output = getOutput();
+  SmallVector loopBounds(6);
+  for (unsigned dim = 0; dim < 6; ++dim) {
+loopBounds[dim].offset = zeroAttr;
+loopBounds[dim].size = getDimValue(builder, loc, output, dim);
+loopBounds[dim].stride = oneAttr;
+  }
+  return loopBounds;
+}
+
+SmallVector
+WinogradInputTransformOp::getLoopIteratorTypes() {
+  SmallVector iteratorTypes(6,
+ 
utils::IteratorType::parallel);
+  return iteratorTypes;
+}
+
+LogicalResult WinogradInputTransformOp::getResultTilePosition(
+OpBuilder &builder, unsigned resultNumber, ArrayRef offsets,
+ArrayRef sizes, SmallVector &resultOffsets,
+SmallVector &resultSizes) {
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  auto oneAttr = builder.getI64IntegerAttr(1);
+
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(offsets[2]);
+  resultOffsets.push_back(offsets[3]);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultSizes.push_back(sizes[0]);
+  resultSizes.push_back(sizes[1]);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(sizes[4]);
+  resultSizes.push_back(sizes[5]);

ftynse wrote:

Nit: something like `resultOffsets.append({zeroAttr, zeroAttr, offsets[2], 
offsets[3], zeroAttr, zeroAttr})` may be more readable.

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits

https://github.com/ftynse edited https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2810,9 +2819,117 @@ LogicalResult WinogradInputTransformOp::verify() {
   if (failed(verifyCompatibleShape(expectedOutputShape, outputShape))) {
 return emitOpError("the output shape is not expected");
   }
+
   return success();
 }
 
+SmallVector
+WinogradInputTransformOp::getIterationDomain(OpBuilder &builder) {
+  Location loc = getLoc();
+  auto indexType = builder.getIndexType();
+  auto zeroAttr = builder.getIntegerAttr(indexType, 0);
+  auto oneAttr = builder.getIntegerAttr(indexType, 1);
+  Value output = getOutput();
+  SmallVector loopBounds(6);
+  for (unsigned dim = 0; dim < 6; ++dim) {
+loopBounds[dim].offset = zeroAttr;
+loopBounds[dim].size = getDimValue(builder, loc, output, dim);
+loopBounds[dim].stride = oneAttr;
+  }
+  return loopBounds;
+}
+
+SmallVector
+WinogradInputTransformOp::getLoopIteratorTypes() {
+  SmallVector iteratorTypes(6,
+ 
utils::IteratorType::parallel);
+  return iteratorTypes;
+}
+
+LogicalResult WinogradInputTransformOp::getResultTilePosition(
+OpBuilder &builder, unsigned resultNumber, ArrayRef offsets,
+ArrayRef sizes, SmallVector &resultOffsets,
+SmallVector &resultSizes) {
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  auto oneAttr = builder.getI64IntegerAttr(1);
+
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(offsets[2]);
+  resultOffsets.push_back(offsets[3]);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultSizes.push_back(sizes[0]);
+  resultSizes.push_back(sizes[1]);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(sizes[4]);
+  resultSizes.push_back(sizes[5]);
+
+  return success();
+}
+
+FailureOr
+WinogradInputTransformOp::getTiledImplementation(OpBuilder &builder,
+ ArrayRef 
offsets,
+ ArrayRef sizes) 
{
+  auto oneAttr = builder.getI64IntegerAttr(1);
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  Value input = getInput();
+  auto inputType = cast(input.getType());
+  auto inputShape = inputType.getShape();
+  int64_t inputH = inputShape[1];
+  int64_t inputW = inputShape[2];
+  int64_t m = getM();
+  int64_t r = getR();
+  int64_t alpha = m + r - 1;
+  int64_t alphaH = inputH != 1 ? alpha : 1;
+  int64_t alphaW = inputW != 1 ? alpha : 1;
+  auto alphaHAttr = builder.getI64IntegerAttr(alphaH);
+  auto alphaWAttr = builder.getI64IntegerAttr(alphaW);
+
+  Location loc = getLoc();
+  SmallVector tiledOperands;
+  SmallVector sliceOffsets, sliceSizes;
+
+  auto context = builder.getContext();
+  auto affineMap =
+  AffineMap::get(1, 0, {builder.getAffineDimExpr(0) * m}, context);
+  Value mappedOffset1 = builder.create(
+  loc, affineMap, getValueFromOpFoldResult(offsets[2], builder, loc));
+  Value mappedOffset2 = builder.create(
+  loc, affineMap, getValueFromOpFoldResult(offsets[3], builder, loc));
+
+  sliceOffsets.push_back(zeroAttr);
+  sliceOffsets.push_back(mappedOffset1);
+  sliceOffsets.push_back(mappedOffset2);
+  sliceOffsets.push_back(zeroAttr);
+  sliceSizes.push_back(sizes[4]);
+  sliceSizes.push_back(alphaHAttr);
+  sliceSizes.push_back(alphaWAttr);
+  sliceSizes.push_back(sizes[5]);
+  SmallVector inputStrides(4, oneAttr);
+  tiledOperands.emplace_back(builder.create(
+  loc, getInput(), sliceOffsets, sliceSizes, inputStrides));
+
+  sliceOffsets.clear();
+  sliceSizes.clear();

ftynse wrote:

I'd rather declare new vectors for this.

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2810,9 +2819,117 @@ LogicalResult WinogradInputTransformOp::verify() {
   if (failed(verifyCompatibleShape(expectedOutputShape, outputShape))) {
 return emitOpError("the output shape is not expected");
   }
+
   return success();
 }
 
+SmallVector
+WinogradInputTransformOp::getIterationDomain(OpBuilder &builder) {
+  Location loc = getLoc();
+  auto indexType = builder.getIndexType();
+  auto zeroAttr = builder.getIntegerAttr(indexType, 0);
+  auto oneAttr = builder.getIntegerAttr(indexType, 1);
+  Value output = getOutput();
+  SmallVector loopBounds(6);
+  for (unsigned dim = 0; dim < 6; ++dim) {
+loopBounds[dim].offset = zeroAttr;
+loopBounds[dim].size = getDimValue(builder, loc, output, dim);
+loopBounds[dim].stride = oneAttr;
+  }
+  return loopBounds;
+}
+
+SmallVector
+WinogradInputTransformOp::getLoopIteratorTypes() {
+  SmallVector iteratorTypes(6,
+ 
utils::IteratorType::parallel);
+  return iteratorTypes;
+}
+
+LogicalResult WinogradInputTransformOp::getResultTilePosition(
+OpBuilder &builder, unsigned resultNumber, ArrayRef offsets,
+ArrayRef sizes, SmallVector &resultOffsets,
+SmallVector &resultSizes) {
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  auto oneAttr = builder.getI64IntegerAttr(1);
+
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(offsets[2]);
+  resultOffsets.push_back(offsets[3]);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultSizes.push_back(sizes[0]);
+  resultSizes.push_back(sizes[1]);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(sizes[4]);
+  resultSizes.push_back(sizes[5]);
+
+  return success();
+}
+
+FailureOr
+WinogradInputTransformOp::getTiledImplementation(OpBuilder &builder,
+ ArrayRef 
offsets,
+ ArrayRef sizes) 
{
+  auto oneAttr = builder.getI64IntegerAttr(1);
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  Value input = getInput();
+  auto inputType = cast(input.getType());
+  auto inputShape = inputType.getShape();
+  int64_t inputH = inputShape[1];
+  int64_t inputW = inputShape[2];
+  int64_t m = getM();
+  int64_t r = getR();
+  int64_t alpha = m + r - 1;
+  int64_t alphaH = inputH != 1 ? alpha : 1;
+  int64_t alphaW = inputW != 1 ? alpha : 1;
+  auto alphaHAttr = builder.getI64IntegerAttr(alphaH);
+  auto alphaWAttr = builder.getI64IntegerAttr(alphaW);
+
+  Location loc = getLoc();
+  SmallVector tiledOperands;
+  SmallVector sliceOffsets, sliceSizes;
+
+  auto context = builder.getContext();
+  auto affineMap =
+  AffineMap::get(1, 0, {builder.getAffineDimExpr(0) * m}, context);
+  Value mappedOffset1 = builder.create(
+  loc, affineMap, getValueFromOpFoldResult(offsets[2], builder, loc));
+  Value mappedOffset2 = builder.create(
+  loc, affineMap, getValueFromOpFoldResult(offsets[3], builder, loc));
+
+  sliceOffsets.push_back(zeroAttr);
+  sliceOffsets.push_back(mappedOffset1);
+  sliceOffsets.push_back(mappedOffset2);
+  sliceOffsets.push_back(zeroAttr);
+  sliceSizes.push_back(sizes[4]);
+  sliceSizes.push_back(alphaHAttr);
+  sliceSizes.push_back(alphaWAttr);
+  sliceSizes.push_back(sizes[5]);
+  SmallVector inputStrides(4, oneAttr);
+  tiledOperands.emplace_back(builder.create(
+  loc, getInput(), sliceOffsets, sliceSizes, inputStrides));
+
+  sliceOffsets.clear();
+  sliceSizes.clear();
+  if (failed(getResultTilePosition(builder, 1, offsets, sizes, sliceOffsets,
+   sliceSizes)))
+return failure();
+
+  SmallVector outputStrides(6, oneAttr);
+  tiledOperands.emplace_back(builder.create(
+  loc, getOutput(), sliceOffsets, sliceSizes, outputStrides));
+
+  SmallVector resultTypes;

ftynse wrote:

```suggestion
  SmallVector resultTypes;
```

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits

https://github.com/ftynse commented:

Looks okay to me in general. Something went wrong with rebases so I see code 
that doesn't belong to this change. Let me know when you merged the bases and I 
can click-approve this one.

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2776,6 +2776,15 @@ LogicalResult WinogradFilterTransformOp::verify() {
 // WinogradInputTransformOp
 
//===--===//
 
+Value getValueFromOpFoldResult(OpFoldResult opFoldResult, OpBuilder &builder,
+   Location loc) {
+  if (auto attr = opFoldResult.dyn_cast()) {
+auto intAttr = cast(attr);
+return builder.create(loc, intAttr);
+  }
+  return opFoldResult.get();
+}

ftynse wrote:

https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/Arith/Utils/Utils.h#L68-L72
 it already exists

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread Oleksandr Alex Zinenko via llvm-branch-commits


@@ -2810,9 +2819,117 @@ LogicalResult WinogradInputTransformOp::verify() {
   if (failed(verifyCompatibleShape(expectedOutputShape, outputShape))) {
 return emitOpError("the output shape is not expected");
   }
+
   return success();
 }
 
+SmallVector
+WinogradInputTransformOp::getIterationDomain(OpBuilder &builder) {
+  Location loc = getLoc();
+  auto indexType = builder.getIndexType();
+  auto zeroAttr = builder.getIntegerAttr(indexType, 0);
+  auto oneAttr = builder.getIntegerAttr(indexType, 1);
+  Value output = getOutput();
+  SmallVector loopBounds(6);
+  for (unsigned dim = 0; dim < 6; ++dim) {
+loopBounds[dim].offset = zeroAttr;
+loopBounds[dim].size = getDimValue(builder, loc, output, dim);
+loopBounds[dim].stride = oneAttr;
+  }
+  return loopBounds;
+}
+
+SmallVector
+WinogradInputTransformOp::getLoopIteratorTypes() {
+  SmallVector iteratorTypes(6,
+ 
utils::IteratorType::parallel);
+  return iteratorTypes;
+}
+
+LogicalResult WinogradInputTransformOp::getResultTilePosition(
+OpBuilder &builder, unsigned resultNumber, ArrayRef offsets,
+ArrayRef sizes, SmallVector &resultOffsets,
+SmallVector &resultSizes) {
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  auto oneAttr = builder.getI64IntegerAttr(1);
+
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(offsets[2]);
+  resultOffsets.push_back(offsets[3]);
+  resultOffsets.push_back(zeroAttr);
+  resultOffsets.push_back(zeroAttr);
+  resultSizes.push_back(sizes[0]);
+  resultSizes.push_back(sizes[1]);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(oneAttr);
+  resultSizes.push_back(sizes[4]);
+  resultSizes.push_back(sizes[5]);
+
+  return success();
+}
+
+FailureOr
+WinogradInputTransformOp::getTiledImplementation(OpBuilder &builder,
+ ArrayRef 
offsets,
+ ArrayRef sizes) 
{
+  auto oneAttr = builder.getI64IntegerAttr(1);
+  auto zeroAttr = builder.getI64IntegerAttr(0);
+  Value input = getInput();
+  auto inputType = cast(input.getType());
+  auto inputShape = inputType.getShape();

ftynse wrote:

Here and below.

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][OpenMP] Remove compound directives from `checkNestingOfRegions` (PR #98387)

2024-07-11 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz updated 
https://github.com/llvm/llvm-project/pull/98387

>From 263c2357cd686e63b5b78985d3c8c6f3635e69cc Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Wed, 10 Jul 2024 09:35:56 -0500
Subject: [PATCH 1/2] [clang][OpenMP] Remove compound directives from
 `checkNestingOfRegions`

Express the constraints via constituent directives.
---
 clang/lib/Sema/SemaOpenMP.cpp | 107 +-
 1 file changed, 53 insertions(+), 54 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index ef09e53077f47..5861923582eb1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4797,6 +4797,12 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 ShouldBeInTeamsRegion,
 ShouldBeInLoopSimdRegion,
   } Recommend = NoRecommend;
+
+  SmallVector LeafOrComposite;
+  ArrayRef ParentLOC =
+  getLeafOrCompositeConstructs(ParentRegion, LeafOrComposite);
+  OpenMPDirectiveKind EnclosingConstruct = ParentLOC.back();
+
   if (SemaRef.LangOpts.OpenMP >= 51 && Stack->isParentOrderConcurrent() &&
   CurrentRegion != OMPD_simd && CurrentRegion != OMPD_loop &&
   CurrentRegion != OMPD_parallel &&
@@ -4805,6 +4811,7 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 << getOpenMPDirectiveName(CurrentRegion);
 return true;
   }
+
   if (isOpenMPSimdDirective(ParentRegion) &&
   ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) ||
(SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion != OMPD_ordered &&
@@ -4828,19 +4835,20 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 << (SemaRef.LangOpts.OpenMP >= 50 ? 1 : 0);
 return CurrentRegion != OMPD_simd;
   }
-  if (ParentRegion == OMPD_atomic) {
+
+  if (EnclosingConstruct == OMPD_atomic) {
 // OpenMP [2.16, Nesting of Regions]
 // OpenMP constructs may not be nested inside an atomic region.
 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_atomic);
 return true;
   }
+
   if (CurrentRegion == OMPD_section) {
 // OpenMP [2.7.2, sections Construct, Restrictions]
 // Orphaned section directives are prohibited. That is, the section
 // directives must appear within the sections construct and must not be
 // encountered elsewhere in the sections region.
-if (ParentRegion != OMPD_sections &&
-ParentRegion != OMPD_parallel_sections) {
+if (EnclosingConstruct != OMPD_sections) {
   SemaRef.Diag(StartLoc, diag::err_omp_orphaned_section_directive)
   << (ParentRegion != OMPD_unknown)
   << getOpenMPDirectiveName(ParentRegion);
@@ -4848,6 +4856,7 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 }
 return false;
   }
+
   // Allow some constructs (except teams and cancellation constructs) to be
   // orphaned (they could be used in functions, called from OpenMP regions
   // with the required preconditions).
@@ -4856,18 +4865,20 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
   CurrentRegion != OMPD_cancellation_point &&
   CurrentRegion != OMPD_cancel && CurrentRegion != OMPD_scan)
 return false;
+
   // Checks needed for mapping "loop" construct. Please check mapLoopConstruct
   // for a detailed explanation
   if (SemaRef.LangOpts.OpenMP >= 50 && CurrentRegion == OMPD_loop &&
   (BindKind == OMPC_BIND_parallel || BindKind == OMPC_BIND_teams) &&
   (isOpenMPWorksharingDirective(ParentRegion) ||
-   ParentRegion == OMPD_loop)) {
+   EnclosingConstruct == OMPD_loop)) {
 int ErrorMsgNumber = (BindKind == OMPC_BIND_parallel) ? 1 : 4;
 SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
 << true << getOpenMPDirectiveName(ParentRegion) << ErrorMsgNumber
 << getOpenMPDirectiveName(CurrentRegion);
 return true;
   }
+
   if (CurrentRegion == OMPD_cancellation_point ||
   CurrentRegion == OMPD_cancel) {
 // OpenMP [2.16, Nesting of Regions]
@@ -4881,27 +4892,17 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
 // construct-type-clause is not taskgroup must be closely nested inside an
 // OpenMP construct that matches the type specified in
 // construct-type-clause.
-NestingProhibited =
-!((CancelRegion == OMPD_parallel &&
-   (ParentRegion == OMPD_parallel ||
-ParentRegion == OMPD_target_parallel)) ||
-  (CancelRegion == OMPD_for &&
-   (ParentRegion == OMPD_for || ParentRegion == OMPD_parallel_for ||
-ParentRegion == OMPD_target_parallel_for ||
-ParentRegion == OMPD_distribute_parallel_for ||
-ParentRegion == OMPD_teams_distribute_parallel_for ||
-ParentRegion == OMPD_target_teams_distribute_parallel_for)) ||
-  (CancelRegion == OMPD_taskgroup &&
-   (ParentRegion == OMPD_task ||
-

[llvm-branch-commits] [llvm] fadfc1a - Revert "Revert "[LowerMemIntrinsics] Use correct alignment in residual loop f…"

2024-07-11 Thread via llvm-branch-commits

Author: Fabian Ritter
Date: 2024-07-11T15:17:49+02:00
New Revision: fadfc1a02d9d4c6cf9e73275572712512e7eb91d

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

LOG: Revert "Revert "[LowerMemIntrinsics] Use correct alignment in residual 
loop f…"

This reverts commit 17316a59895daabfa23e7534f686c08a0949fe09.

Added: 


Modified: 
llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll

Removed: 




diff  --git a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp 
b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
index d2814f07530d8..b38db412f786a 100644
--- a/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
+++ b/llvm/lib/Transforms/Utils/LowerMemIntrinsics.cpp
@@ -262,6 +262,9 @@ void llvm::createMemCpyLoopUnknownSize(
 assert((ResLoopOpSize == AtomicElementSize ? *AtomicElementSize : 1) &&
"Store size is expected to match type size");
 
+Align ResSrcAlign(commonAlignment(PartSrcAlign, ResLoopOpSize));
+Align ResDstAlign(commonAlignment(PartDstAlign, ResLoopOpSize));
+
 Value *RuntimeResidual = getRuntimeLoopRemainder(DL, PLBuilder, CopyLen,
  CILoopOpSize, LoopOpSize);
 Value *RuntimeBytesCopied = PLBuilder.CreateSub(CopyLen, RuntimeResidual);
@@ -303,7 +306,7 @@ void llvm::createMemCpyLoopUnknownSize(
 Value *SrcGEP =
 ResBuilder.CreateInBoundsGEP(ResLoopOpType, SrcAddr, FullOffset);
 LoadInst *Load = ResBuilder.CreateAlignedLoad(ResLoopOpType, SrcGEP,
-  PartSrcAlign, SrcIsVolatile);
+  ResSrcAlign, SrcIsVolatile);
 if (!CanOverlap) {
   // Set alias scope for loads.
   Load->setMetadata(LLVMContext::MD_alias_scope,
@@ -311,8 +314,8 @@ void llvm::createMemCpyLoopUnknownSize(
 }
 Value *DstGEP =
 ResBuilder.CreateInBoundsGEP(ResLoopOpType, DstAddr, FullOffset);
-StoreInst *Store = ResBuilder.CreateAlignedStore(Load, DstGEP, 
PartDstAlign,
- DstIsVolatile);
+StoreInst *Store =
+ResBuilder.CreateAlignedStore(Load, DstGEP, ResDstAlign, 
DstIsVolatile);
 if (!CanOverlap) {
   // Indicate that stores don't overlap loads.
   Store->setMetadata(LLVMContext::MD_noalias, MDNode::get(Ctx, NewScope));

diff  --git a/llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll 
b/llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll
index d53db69f9f2e0..5cb57ee112b3a 100644
--- a/llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll
+++ b/llvm/test/CodeGen/AMDGPU/lower-mem-intrinsics.ll
@@ -930,9 +930,9 @@ define amdgpu_kernel void 
@memcpy_global_align4_global_align4_variable(ptr addrs
 ; OPT-NEXT:[[RESIDUAL_LOOP_INDEX:%.*]] = phi i64 [ 0, 
[[LOOP_MEMCPY_RESIDUAL_HEADER]] ], [ [[TMP14:%.*]], 
[[LOOP_MEMCPY_RESIDUAL:%.*]] ]
 ; OPT-NEXT:[[TMP10:%.*]] = add i64 [[TMP3]], [[RESIDUAL_LOOP_INDEX]]
 ; OPT-NEXT:[[TMP11:%.*]] = getelementptr inbounds i8, ptr addrspace(1) 
[[SRC]], i64 [[TMP10]]
-; OPT-NEXT:[[TMP12:%.*]] = load i8, ptr addrspace(1) [[TMP11]], align 4
+; OPT-NEXT:[[TMP12:%.*]] = load i8, ptr addrspace(1) [[TMP11]], align 1
 ; OPT-NEXT:[[TMP13:%.*]] = getelementptr inbounds i8, ptr addrspace(1) 
[[DST]], i64 [[TMP10]]
-; OPT-NEXT:store i8 [[TMP12]], ptr addrspace(1) [[TMP13]], align 4
+; OPT-NEXT:store i8 [[TMP12]], ptr addrspace(1) [[TMP13]], align 1
 ; OPT-NEXT:[[TMP14]] = add i64 [[RESIDUAL_LOOP_INDEX]], 1
 ; OPT-NEXT:[[TMP15:%.*]] = icmp ult i64 [[TMP14]], [[TMP2]]
 ; OPT-NEXT:br i1 [[TMP15]], label [[LOOP_MEMCPY_RESIDUAL]], label 
[[POST_LOOP_MEMCPY_EXPANSION:%.*]]
@@ -966,9 +966,9 @@ define amdgpu_kernel void 
@memcpy_global_align2_global_align2_variable(ptr addrs
 ; OPT-NEXT:[[RESIDUAL_LOOP_INDEX:%.*]] = phi i64 [ 0, 
[[LOOP_MEMCPY_RESIDUAL_HEADER]] ], [ [[TMP14:%.*]], 
[[LOOP_MEMCPY_RESIDUAL:%.*]] ]
 ; OPT-NEXT:[[TMP10:%.*]] = add i64 [[TMP3]], [[RESIDUAL_LOOP_INDEX]]
 ; OPT-NEXT:[[TMP11:%.*]] = getelementptr inbounds i8, ptr addrspace(1) 
[[SRC]], i64 [[TMP10]]
-; OPT-NEXT:[[TMP12:%.*]] = load i8, ptr addrspace(1) [[TMP11]], align 2
+; OPT-NEXT:[[TMP12:%.*]] = load i8, ptr addrspace(1) [[TMP11]], align 1
 ; OPT-NEXT:[[TMP13:%.*]] = getelementptr inbounds i8, ptr addrspace(1) 
[[DST]], i64 [[TMP10]]
-; OPT-NEXT:store i8 [[TMP12]], ptr addrspace(1) [[TMP13]], align 2
+; OPT-NEXT:store i8 [[TMP12]], ptr addrspace(1) [[TMP13]], align 1
 ; OPT-NEXT:[[TMP14]] = add i64 [[RESIDUAL_LOOP_INDEX]], 1
 ; OPT-NEXT:[[TMP15:%.*]] = icmp ult i64 [[TMP14]], [[TMP2]]
 ; OPT-NEXT:br i1 [[TMP15]], label [[LOOP_MEMCPY_RESIDUAL]], label 
[[POST_LOOP_MEMCPY_EXPANSION:%.*]]
@@ -1038,9 +103

[llvm-branch-commits] [llvm] 2dae7c4 - Revert "[LV] Autovectorization for the all-in-one histogram intrinsic (#91458)"

2024-07-11 Thread via llvm-branch-commits

Author: Graham Hunter
Date: 2024-07-11T16:14:47+01:00
New Revision: 2dae7c40fdd7233b6ac5d5a7513417c4f5d4f398

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

LOG: Revert "[LV] Autovectorization for the all-in-one histogram intrinsic 
(#91458)"

This reverts commit 1860fd049e35055fccac14e439227fae803976b8.

Added: 


Modified: 
llvm/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
llvm/lib/Analysis/LoopAccessAnalysis.cpp
llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/lib/Transforms/Vectorize/VPlanValue.h

Removed: 
llvm/test/Analysis/LoopAccessAnalysis/histogram.ll
llvm/test/Transforms/LoopVectorize/AArch64/sve2-histcnt.ll



diff  --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h 
b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 9cca70459edef..f6bb044392938 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -144,9 +144,7 @@ class MemoryDepChecker {
   // on MinDepDistBytes.
   BackwardVectorizable,
   // Same, but may prevent store-to-load forwarding.
-  BackwardVectorizableButPreventsForwarding,
-  // Access is to a loop loaded value, but is part of a histogram 
operation.
-  Histogram
+  BackwardVectorizableButPreventsForwarding
 };
 
 /// String version of the types.
@@ -203,8 +201,7 @@ class MemoryDepChecker {
   /// Only checks sets with elements in \p CheckDeps.
   bool areDepsSafe(DepCandidates &AccessSets, MemAccessInfoList &CheckDeps,
const DenseMap>
-   &UnderlyingObjects,
-   const SmallPtrSetImpl &HistogramPtrs);
+   &UnderlyingObjects);
 
   /// No memory dependence was encountered that would inhibit
   /// vectorization.
@@ -355,8 +352,7 @@ class MemoryDepChecker {
   isDependent(const MemAccessInfo &A, unsigned AIdx, const MemAccessInfo &B,
   unsigned BIdx,
   const DenseMap>
-  &UnderlyingObjects,
-  const SmallPtrSetImpl &HistogramPtrs);
+  &UnderlyingObjects);
 
   /// Check whether the data dependence could prevent store-load
   /// forwarding.
@@ -397,8 +393,7 @@ class MemoryDepChecker {
   const MemAccessInfo &A, Instruction *AInst, const MemAccessInfo &B,
   Instruction *BInst,
   const DenseMap>
-  &UnderlyingObjects,
-  const SmallPtrSetImpl &HistogramPtrs);
+  &UnderlyingObjects);
 };
 
 class RuntimePointerChecking;
@@ -450,15 +445,6 @@ struct PointerDiffInfo {
 NeedsFreeze(NeedsFreeze) {}
 };
 
-struct HistogramInfo {
-  LoadInst *Load;
-  Instruction *Update;
-  StoreInst *Store;
-
-  HistogramInfo(LoadInst *Load, Instruction *Update, StoreInst *Store)
-  : Load(Load), Update(Update), Store(Store) {}
-};
-
 /// Holds information about the memory runtime legality checks to verify
 /// that a group of pointers do not overlap.
 class RuntimePointerChecking {
@@ -639,13 +625,6 @@ class RuntimePointerChecking {
 /// Checks for both memory dependences and the SCEV predicates contained in the
 /// PSE must be emitted in order for the results of this analysis to be valid.
 class LoopAccessInfo {
-  /// Represents whether the memory access dependencies in the loop:
-  ///   * Prohibit vectorization
-  ///   * Allow for vectorization (possibly with runtime checks)
-  ///   * Allow for vectorization (possibly with runtime checks),
-  /// as long as histogram operations are supported.
-  enum VecMemPossible { CantVec = 0, NormalVec = 1, HistogramVec = 2 };
-
 public:
   LoopAccessInfo(Loop *L, ScalarEvolution *SE, const TargetTransformInfo *TTI,
  const TargetLibraryInfo *TLI, AAResults *AA, DominatorTree 
*DT,
@@ -657,11 +636,7 @@ class LoopAccessInfo {
   /// hasStoreStoreDependenceInvolvingLoopInvariantAddress and
   /// hasLoadStoreDependenceInvolvingLoopInvariantAddress also need to be
   /// checked.
-  bool canVectorizeMemory() const { return CanVecMem == NormalVec; }
-
-  bool canVectorizeMemoryWithHistogram() const {
-return CanVecMem == NormalVec || CanVecMem == HistogramVec;
-  }
+  bool canVectorizeMemory() const { return CanVecMem; }
 
   /// Return true if there is a convergent operation in the loop. There may
   /// still be reported runtime pointer checks that would be required, but it 
is
@@ -689,10 +664,6 @@ class LoopAccessInfo {
   unsigned getNumStores() const { return NumS

[llvm-branch-commits] [llvm] c8547d8 - Revert "[MC] set OpenBSD's ELFOSABI by default (#98158)"

2024-07-11 Thread via llvm-branch-commits

Author: Mehdi Amini
Date: 2024-07-11T17:16:03+02:00
New Revision: c8547d829c5a738a1fe37ff4ecea5c272cb2eaf0

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

LOG: Revert "[MC] set OpenBSD's ELFOSABI by default (#98158)"

This reverts commit b64c1de714c50bec7493530446ebf5e540d5f96a.

Added: 


Modified: 
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/test/MC/ELF/osabi.s

Removed: 




diff  --git a/llvm/include/llvm/MC/MCELFObjectWriter.h 
b/llvm/include/llvm/MC/MCELFObjectWriter.h
index 12237094ad86a..d7c223cdcc07f 100644
--- a/llvm/include/llvm/MC/MCELFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -78,8 +78,6 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
 return ELF::ELFOSABI_FREEBSD;
   case Triple::Solaris:
 return ELF::ELFOSABI_SOLARIS;
-  case Triple::OpenBSD:
-return ELF::ELFOSABI_OPENBSD;
   default:
 return ELF::ELFOSABI_NONE;
 }

diff  --git a/llvm/test/MC/ELF/osabi.s b/llvm/test/MC/ELF/osabi.s
index 44912f4987c11..dc6ad2a349d75 100644
--- a/llvm/test/MC/ELF/osabi.s
+++ b/llvm/test/MC/ELF/osabi.s
@@ -10,7 +10,3 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s | llvm-readobj 
-h - | \
 # RUN:   FileCheck %s --check-prefix=FREEBSD
 # FREEBSD: OS/ABI: FreeBSD
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-openbsd %s | llvm-readobj 
-h - | \
-# RUN:   FileCheck %s --check-prefix=OPENBSD
-# OPENBSD: OS/ABI: OpenBSD



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov approved this pull request.

Suggestion: `createReturnInstructionList`

https://github.com/llvm/llvm-project/pull/98448
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)

2024-07-11 Thread Amir Ayupov via llvm-branch-commits

https://github.com/aaupov approved this pull request.

Awesome, thanks for updating the documentation

https://github.com/llvm/llvm-project/pull/98162
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT] Added more details on heatmap docs. (PR #98162)

2024-07-11 Thread Amir Ayupov via llvm-branch-commits

aaupov wrote:

Please retitle as imperative statement and drop trailing dot, e.g. 
`[BOLT][docs] Expand Heatmaps.md`

https://github.com/llvm/llvm-project/pull/98162
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][OpenMP] Update validity check for reduction with `inscan` (PR #98500)

2024-07-11 Thread Krzysztof Parzyszek via llvm-branch-commits

https://github.com/kparzysz created 
https://github.com/llvm/llvm-project/pull/98500

Follow-up to 81cdf9472c (check for `scan` nesting).  Also, it eliminates the 
mentions of combined directives in `ActOnOpenMPReductionClause`.

>From b58e4fae4b0c22c11e8a0d0e29b6f21c28d4da86 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek 
Date: Thu, 11 Jul 2024 10:47:41 -0500
Subject: [PATCH] [clang][OpenMP] Update validity check for reduction with
 `inscan`

Follow-up to 81cdf9472c (check for `scan` nesting).  Also, it eliminates
the mentions of combined directives in `ActOnOpenMPReductionClause`.
---
 clang/lib/Sema/SemaOpenMP.cpp | 24 
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 7ca89b0d4eb70..dc77a51b6569e 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -18603,14 +18603,22 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
   // worksharing-loop construct, a worksharing-loop SIMD construct, a simd
   // construct, a parallel worksharing-loop construct or a parallel
   // worksharing-loop SIMD construct.
-  if (Modifier == OMPC_REDUCTION_inscan &&
-  (DSAStack->getCurrentDirective() != OMPD_for &&
-   DSAStack->getCurrentDirective() != OMPD_for_simd &&
-   DSAStack->getCurrentDirective() != OMPD_simd &&
-   DSAStack->getCurrentDirective() != OMPD_parallel_for &&
-   DSAStack->getCurrentDirective() != OMPD_parallel_for_simd)) {
-Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
-return nullptr;
+  // [5.2:136:1-4] A reduction clause with the inscan reduction-modifier may
+  // only appear on a worksharing-loop construct, a simd construct or a
+  // combined or composite construct for which any of the aforementioned
+  // constructs is a constituent construct and distribute is not a constituent
+  // construct.
+  if (Modifier == OMPC_REDUCTION_inscan) {
+SmallVector LeafOrComposite;
+ArrayRef CurrentLOC = getLeafOrCompositeConstructs(
+DSAStack->getCurrentDirective(), LeafOrComposite);
+bool Valid = llvm::any_of(CurrentLOC, [](OpenMPDirectiveKind DK) {
+  return llvm::is_contained({OMPD_for, OMPD_simd, OMPD_for_simd}, DK);
+});
+if (!Valid) {
+  Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
+  return nullptr;
+}
   }
 
   ReductionData RD(VarList.size(), Modifier);

___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [NFC][BOLT] Rename createDummyReturnFunction to createReturnBody (PR #98448)

2024-07-11 Thread Pavel Samolysov via llvm-branch-commits

https://github.com/samolisov approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/98448
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [clang][OpenMP] Update validity check for reduction with `inscan` (PR #98500)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krzysztof Parzyszek (kparzysz)


Changes

Follow-up to 81cdf9472c (check for `scan` nesting).  Also, it eliminates the 
mentions of combined directives in `ActOnOpenMPReductionClause`.

---
Full diff: https://github.com/llvm/llvm-project/pull/98500.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaOpenMP.cpp (+16-8) 


``diff
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 7ca89b0d4eb70..dc77a51b6569e 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -18603,14 +18603,22 @@ OMPClause *SemaOpenMP::ActOnOpenMPReductionClause(
   // worksharing-loop construct, a worksharing-loop SIMD construct, a simd
   // construct, a parallel worksharing-loop construct or a parallel
   // worksharing-loop SIMD construct.
-  if (Modifier == OMPC_REDUCTION_inscan &&
-  (DSAStack->getCurrentDirective() != OMPD_for &&
-   DSAStack->getCurrentDirective() != OMPD_for_simd &&
-   DSAStack->getCurrentDirective() != OMPD_simd &&
-   DSAStack->getCurrentDirective() != OMPD_parallel_for &&
-   DSAStack->getCurrentDirective() != OMPD_parallel_for_simd)) {
-Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
-return nullptr;
+  // [5.2:136:1-4] A reduction clause with the inscan reduction-modifier may
+  // only appear on a worksharing-loop construct, a simd construct or a
+  // combined or composite construct for which any of the aforementioned
+  // constructs is a constituent construct and distribute is not a constituent
+  // construct.
+  if (Modifier == OMPC_REDUCTION_inscan) {
+SmallVector LeafOrComposite;
+ArrayRef CurrentLOC = getLeafOrCompositeConstructs(
+DSAStack->getCurrentDirective(), LeafOrComposite);
+bool Valid = llvm::any_of(CurrentLOC, [](OpenMPDirectiveKind DK) {
+  return llvm::is_contained({OMPD_for, OMPD_simd, OMPD_for_simd}, DK);
+});
+if (!Valid) {
+  Diag(ModifierLoc, diag::err_omp_wrong_inscan_reduction);
+  return nullptr;
+}
   }
 
   ReductionData RD(VarList.size(), Modifier);

``




https://github.com/llvm/llvm-project/pull/98500
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] 8f45544 - Revert "[MachineSink] Fix missing sinks along critical edges (#97618)"

2024-07-11 Thread via llvm-branch-commits

Author: Amara Emerson
Date: 2024-07-11T09:53:09-07:00
New Revision: 8f45544cedba4665716bdb78a4a34c76837467bf

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

LOG: Revert "[MachineSink] Fix missing sinks along critical edges (#97618)"

This reverts commit 7e2f96194fa56148281c0232b4fa0db5c9cabec3.

Added: 


Modified: 
llvm/lib/CodeGen/MachineSink.cpp
llvm/test/CodeGen/AArch64/and-sink.ll
llvm/test/CodeGen/AArch64/fast-isel-branch-cond-split.ll
llvm/test/CodeGen/RISCV/machine-sink-load-immediate.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/MachineSink.cpp 
b/llvm/lib/CodeGen/MachineSink.cpp
index bbc5ab13a0cd3..83c2895f91fbb 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -130,14 +130,6 @@ namespace {
 // Remember which edges have been considered for breaking.
 SmallSet, 8>
 CEBCandidates;
-// Memorize the register that also wanted to sink into the same block along
-// a 
diff erent critical edge.
-// {register to sink, sink-to block} -> the first sink-from block.
-// We're recording the first sink-from block because that (critical) edge
-// was deferred until we see another register that's going to sink into the
-// same block.
-DenseMap, MachineBasicBlock *>
-CEMergeCandidates;
 // Remember which edges we are about to split.
 // This is 
diff erent from CEBCandidates since those edges
 // will be split.
@@ -205,17 +197,14 @@ namespace {
 
 void releaseMemory() override {
   CEBCandidates.clear();
-  CEMergeCandidates.clear();
 }
 
   private:
 bool ProcessBlock(MachineBasicBlock &MBB);
 void ProcessDbgInst(MachineInstr &MI);
-bool isLegalToBreakCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
-MachineBasicBlock *To, bool BreakPHIEdge);
-bool isWorthBreakingCriticalEdge(MachineInstr &MI, MachineBasicBlock *From,
- MachineBasicBlock *To,
- MachineBasicBlock *&DeferredFromBlock);
+bool isWorthBreakingCriticalEdge(MachineInstr &MI,
+ MachineBasicBlock *From,
+ MachineBasicBlock *To);
 
 bool hasStoreBetween(MachineBasicBlock *From, MachineBasicBlock *To,
  MachineInstr &MI);
@@ -736,7 +725,6 @@ bool MachineSinking::runOnMachineFunction(MachineFunction 
&MF) {
 
 // Process all basic blocks.
 CEBCandidates.clear();
-CEMergeCandidates.clear();
 ToSplit.clear();
 for (auto &MBB: MF)
   MadeChange |= ProcessBlock(MBB);
@@ -885,9 +873,9 @@ void MachineSinking::ProcessDbgInst(MachineInstr &MI) {
   SeenDbgVars.insert(Var);
 }
 
-bool MachineSinking::isWorthBreakingCriticalEdge(
-MachineInstr &MI, MachineBasicBlock *From, MachineBasicBlock *To,
-MachineBasicBlock *&DeferredFromBlock) {
+bool MachineSinking::isWorthBreakingCriticalEdge(MachineInstr &MI,
+ MachineBasicBlock *From,
+ MachineBasicBlock *To) {
   // FIXME: Need much better heuristics.
 
   // If the pass has already considered breaking this edge (during this pass
@@ -899,27 +887,6 @@ bool MachineSinking::isWorthBreakingCriticalEdge(
   if (!MI.isCopy() && !TII->isAsCheapAsAMove(MI))
 return true;
 
-  // Check and record the register and the destination block we want to sink
-  // into. Note that we want to do the following before the next check on 
branch
-  // probability. Because we want to record the initial candidate even if it's
-  // on hot edge, so that other candidates that might not on hot edges can be
-  // sinked as well.
-  for (const auto &MO : MI.all_defs()) {
-Register Reg = MO.getReg();
-if (!Reg)
-  continue;
-Register SrcReg = Reg.isVirtual() ? TRI->lookThruCopyLike(Reg, MRI) : Reg;
-auto Key = std::make_pair(SrcReg, To);
-auto Res = CEMergeCandidates.try_emplace(Key, From);
-// We wanted to sink the same register into the same block, consider it to
-// be profitable.
-if (!Res.second) {
-  // Return the source block that was previously held off.
-  DeferredFromBlock = Res.first->second;
-  return true;
-}
-  }
-
   if (From->isSuccessor(To) && MBPI->getEdgeProbability(From, To) <=
   BranchProbability(SplitEdgeProbabilityThreshold, 100))
 return true;
@@ -954,10 +921,13 @@ bool MachineSinking::isWorthBreakingCriticalEdge(
   return false;
 }
 
-bool MachineSinking::isLegalToBreakCriticalEdge(MachineInstr &MI,
-MachineBasicBlock *FromBB,
-MachineBasicBlock *ToBB,
-

[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung updated 
https://github.com/llvm/llvm-project/pull/98125

>From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 10:04:25 -0700
Subject: [PATCH 1/6] Comments

Created using spr 1.3.4
---
 bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp 
b/bolt/lib/Profile/YAMLProfileReader.cpp
index 69ea0899c5f2c..6753337c24ea7 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 
   // Maps binary functions to adjacent functions in the FCG.
   for (const BinaryFunction *CallerBF : BFs) {
-// Add all call targets to the hash map.
 for (const BinaryBasicBlock &BB : CallerBF->blocks()) {
   for (const MCInst &Inst : BB) {
 if (!BC.MIB->isCall(Instr))
@@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Create mapping from neighbor hash to BFs.
+  // Using the constructed adjacent function mapping, creates mapping from
+  // neighbor hash to BFs.
   std::unordered_map>
   NeighborHashToBFs;
   for (const BinaryFunction *BF : BFs) {
@@ -552,12 +552,12 @@ size_t 
YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
 .push_back(BF);
   }
 
-  // TODO: change call anchor PR to have this representation - we need it here
+  // TODO: note, this will be introduced in the matching functions with calls
+  // as anchors pr
   DenseMap
   IdToYAMLBF;
-  // TODO: change call anchor PR to have this representation - we need it here
 
-  // Maps hashes to profiled functions.
+  // Maps YAML functions to adjacent functions in the profile FCG.
   std::unordered_map
   YamlBFToHashes(BFs.size());
@@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Matching YAMLBF with neighbor hashes.
+  // Matches YAMLBF to BFs with neighbor hashes.
   for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
 if (YamlBF.Used)
   continue;

>From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 13:52:05 -0700
Subject: [PATCH 2/6] Moved blended hash definition

Created using spr 1.3.4
---
 bolt/include/bolt/Profile/YAMLProfileReader.h |  69 ++-
 bolt/lib/Profile/StaleProfileMatching.cpp |  65 ---
 bolt/lib/Profile/YAMLProfileReader.cpp| 110 --
 3 files changed, 119 insertions(+), 125 deletions(-)

diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h 
b/bolt/include/bolt/Profile/YAMLProfileReader.h
index 36e8f8739eee1..e8a34ecad9a08 100644
--- a/bolt/include/bolt/Profile/YAMLProfileReader.h
+++ b/bolt/include/bolt/Profile/YAMLProfileReader.h
@@ -16,6 +16,73 @@
 namespace llvm {
 namespace bolt {
 
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+private:
+  using ValueOffset = Bitfield::Element;
+  using ValueOpcode = Bitfield::Element;
+  using ValueInstr = Bitfield::Element;
+  using ValuePred = Bitfield::Element;
+  using ValueSucc = Bitfield::Element;
+
+public:
+  explicit BlendedBlockHash() {}
+
+  explicit BlendedBlockHash(uint64_t Hash) {
+Offset = Bitfield::get(Hash);
+OpcodeHash = Bitfield::get(Hash);
+InstrHash = Bitfield::get(Hash);
+PredHash = Bitfield::get(Hash);
+SuccHash = Bitfield::get(Hash);
+  }
+
+  /// Combine the blended hash into uint64_t.
+  uint64_t combine() const {
+uint64_t Hash = 0;
+Bitfield::set(Hash, Offset);
+Bitfield::set(Hash, OpcodeHash);
+Bitfield::set(Hash, InstrHash);
+Bitfield::set(Hash, PredHash);
+Bitfield::set(Hash, SuccHash);
+return Hash;
+  }
+
+  /// Compute a distance between two given blended hashes. The smaller the
+  /// distance, the more similar two blocks are. For identical basic blocks,
+  /// the distance is zero.
+  uint64_t distance(const BlendedBlockHash &BBH) const {
+assert(OpcodeHash == BBH.OpcodeHash &&
+   "incorrect blended hash distance computation");
+uint64_t Dist = 0;
+// Account for NeighborHash
+Dist += SuccHash == BBH.SuccHash ? 0 : 1;
+Dist += PredHash == BBH.PredHash ? 0 : 1;
+Dist <<= 16;
+// Account for InstrHash
+Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+Dist <<= 16;
+// Account for Offset
+Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+return Dist;
+  }
+
+  /// The offset of the basic block from the function start.
+  uint16_t Offset{0};
+  /// (Loose) Hash of the basic block instructions, excluding operands.
+  uint16_t OpcodeHash{0};
+  /// (Strong)

[llvm-branch-commits] [clang] ab0a565 - Revert "fix bug that undefined internal is a warning only for -pedantic-error…"

2024-07-11 Thread via llvm-branch-commits

Author: Aaron Ballman
Date: 2024-07-11T12:59:40-04:00
New Revision: ab0a5654ce418b73bbc04dee37e7f2dd4f75a6e4

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

LOG: Revert "fix bug that undefined internal is a warning only for 
-pedantic-error…"

This reverts commit e16882fc7416a30d56d5b5a19d549ca7c653e668.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td

Removed: 
clang/test/Sema/undefined-internal-basic.c
clang/test/Sema/undefined-internal-typeof-c23.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d5446f7fd92cc..c6a2237113ace 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -592,9 +592,6 @@ Attribute Changes in Clang
 
 Improvements to Clang's diagnostics
 ---
-- Clang now emits an error instead of a warning for ``-Wundefined-internal``
-  when compiling with `-pedantic-errors` to conform to the C standard
-
 - Clang now applies syntax highlighting to the code snippets it
   prints.
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0ea3677355169..940f9ac226ca8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6016,7 +6016,7 @@ def note_deleted_assign_field : Note<
   "because field %2 is of %select{reference|const-qualified}4 type %3">;
 
 // These should be errors.
-def warn_undefined_internal : ExtWarn<
+def warn_undefined_internal : Warning<
   "%select{function|variable}0 %q1 has internal linkage but is not defined">,
   InGroup>;
 def err_undefined_internal_type : Error<

diff  --git a/clang/test/Sema/undefined-internal-basic.c 
b/clang/test/Sema/undefined-internal-basic.c
deleted file mode 100644
index baf05d474250e..0
--- a/clang/test/Sema/undefined-internal-basic.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-pointer-arith 
-Wno-gnu-alignof-expression -Wno-unused -pedantic-errors
-
-static void *a(void); // expected-error {{function 'a' has internal linkage 
but is not defined}}
-static void *b(void); // expected-error {{function 'b' has internal linkage 
but is not defined}}
-static void *c(void); // expected-error {{function 'c' has internal linkage 
but is not defined}}
-static void *d(void); // expected-error {{function 'd' has internal linkage 
but is not defined}}
-static void *no_err(void);
-
-int main(void)
-{
-a; // expected-note {{used here}}
-
-int i = _Alignof(no_err);
-
-int j = _Generic(&no_err, void *(*)(void): 0);
-
-void *k = _Generic(&no_err, void *(*)(void): b(), default: 0); // 
expected-note {{used here}}
-
-// FIXME according to the C standard there should be no error if the 
undefined internal is
-// "part of the expression in a generic association that is not the result 
expression of its generic selection;"
-// but, currently, clang wrongly emits an error in this case
-k = _Generic(&no_err, void *(*)(void): 0, default: c()); // expected-note 
{{used here}}
-
-k = _Generic(&no_err, int (*)(void) : 0, default : d()); // expected-note 
{{used here}}
-
-int l = sizeof(no_err);
-
-__typeof__(&no_err) x;
-}

diff  --git a/clang/test/Sema/undefined-internal-typeof-c23.c 
b/clang/test/Sema/undefined-internal-typeof-c23.c
deleted file mode 100644
index 837c36d4910a7..0
--- a/clang/test/Sema/undefined-internal-typeof-c23.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c23 -pedantic-errors
-
-// expected-no-diagnostics
-
-static int f(void);
-
-int main(void)
-{
-typeof(&f) x;
-}



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung updated 
https://github.com/llvm/llvm-project/pull/98125

>From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 10:04:25 -0700
Subject: [PATCH 1/7] Comments

Created using spr 1.3.4
---
 bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp 
b/bolt/lib/Profile/YAMLProfileReader.cpp
index 69ea0899c5f2c..6753337c24ea7 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 
   // Maps binary functions to adjacent functions in the FCG.
   for (const BinaryFunction *CallerBF : BFs) {
-// Add all call targets to the hash map.
 for (const BinaryBasicBlock &BB : CallerBF->blocks()) {
   for (const MCInst &Inst : BB) {
 if (!BC.MIB->isCall(Instr))
@@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Create mapping from neighbor hash to BFs.
+  // Using the constructed adjacent function mapping, creates mapping from
+  // neighbor hash to BFs.
   std::unordered_map>
   NeighborHashToBFs;
   for (const BinaryFunction *BF : BFs) {
@@ -552,12 +552,12 @@ size_t 
YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
 .push_back(BF);
   }
 
-  // TODO: change call anchor PR to have this representation - we need it here
+  // TODO: note, this will be introduced in the matching functions with calls
+  // as anchors pr
   DenseMap
   IdToYAMLBF;
-  // TODO: change call anchor PR to have this representation - we need it here
 
-  // Maps hashes to profiled functions.
+  // Maps YAML functions to adjacent functions in the profile FCG.
   std::unordered_map
   YamlBFToHashes(BFs.size());
@@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Matching YAMLBF with neighbor hashes.
+  // Matches YAMLBF to BFs with neighbor hashes.
   for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
 if (YamlBF.Used)
   continue;

>From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 13:52:05 -0700
Subject: [PATCH 2/7] Moved blended hash definition

Created using spr 1.3.4
---
 bolt/include/bolt/Profile/YAMLProfileReader.h |  69 ++-
 bolt/lib/Profile/StaleProfileMatching.cpp |  65 ---
 bolt/lib/Profile/YAMLProfileReader.cpp| 110 --
 3 files changed, 119 insertions(+), 125 deletions(-)

diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h 
b/bolt/include/bolt/Profile/YAMLProfileReader.h
index 36e8f8739eee1..e8a34ecad9a08 100644
--- a/bolt/include/bolt/Profile/YAMLProfileReader.h
+++ b/bolt/include/bolt/Profile/YAMLProfileReader.h
@@ -16,6 +16,73 @@
 namespace llvm {
 namespace bolt {
 
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+private:
+  using ValueOffset = Bitfield::Element;
+  using ValueOpcode = Bitfield::Element;
+  using ValueInstr = Bitfield::Element;
+  using ValuePred = Bitfield::Element;
+  using ValueSucc = Bitfield::Element;
+
+public:
+  explicit BlendedBlockHash() {}
+
+  explicit BlendedBlockHash(uint64_t Hash) {
+Offset = Bitfield::get(Hash);
+OpcodeHash = Bitfield::get(Hash);
+InstrHash = Bitfield::get(Hash);
+PredHash = Bitfield::get(Hash);
+SuccHash = Bitfield::get(Hash);
+  }
+
+  /// Combine the blended hash into uint64_t.
+  uint64_t combine() const {
+uint64_t Hash = 0;
+Bitfield::set(Hash, Offset);
+Bitfield::set(Hash, OpcodeHash);
+Bitfield::set(Hash, InstrHash);
+Bitfield::set(Hash, PredHash);
+Bitfield::set(Hash, SuccHash);
+return Hash;
+  }
+
+  /// Compute a distance between two given blended hashes. The smaller the
+  /// distance, the more similar two blocks are. For identical basic blocks,
+  /// the distance is zero.
+  uint64_t distance(const BlendedBlockHash &BBH) const {
+assert(OpcodeHash == BBH.OpcodeHash &&
+   "incorrect blended hash distance computation");
+uint64_t Dist = 0;
+// Account for NeighborHash
+Dist += SuccHash == BBH.SuccHash ? 0 : 1;
+Dist += PredHash == BBH.PredHash ? 0 : 1;
+Dist <<= 16;
+// Account for InstrHash
+Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+Dist <<= 16;
+// Account for Offset
+Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+return Dist;
+  }
+
+  /// The offset of the basic block from the function start.
+  uint16_t Offset{0};
+  /// (Loose) Hash of the basic block instructions, excluding operands.
+  uint16_t OpcodeHash{0};
+  /// (Strong)

[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung updated 
https://github.com/llvm/llvm-project/pull/98125

>From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 10:04:25 -0700
Subject: [PATCH 1/8] Comments

Created using spr 1.3.4
---
 bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp 
b/bolt/lib/Profile/YAMLProfileReader.cpp
index 69ea0899c5f2c..6753337c24ea7 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 
   // Maps binary functions to adjacent functions in the FCG.
   for (const BinaryFunction *CallerBF : BFs) {
-// Add all call targets to the hash map.
 for (const BinaryBasicBlock &BB : CallerBF->blocks()) {
   for (const MCInst &Inst : BB) {
 if (!BC.MIB->isCall(Instr))
@@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Create mapping from neighbor hash to BFs.
+  // Using the constructed adjacent function mapping, creates mapping from
+  // neighbor hash to BFs.
   std::unordered_map>
   NeighborHashToBFs;
   for (const BinaryFunction *BF : BFs) {
@@ -552,12 +552,12 @@ size_t 
YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
 .push_back(BF);
   }
 
-  // TODO: change call anchor PR to have this representation - we need it here
+  // TODO: note, this will be introduced in the matching functions with calls
+  // as anchors pr
   DenseMap
   IdToYAMLBF;
-  // TODO: change call anchor PR to have this representation - we need it here
 
-  // Maps hashes to profiled functions.
+  // Maps YAML functions to adjacent functions in the profile FCG.
   std::unordered_map
   YamlBFToHashes(BFs.size());
@@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Matching YAMLBF with neighbor hashes.
+  // Matches YAMLBF to BFs with neighbor hashes.
   for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
 if (YamlBF.Used)
   continue;

>From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 13:52:05 -0700
Subject: [PATCH 2/8] Moved blended hash definition

Created using spr 1.3.4
---
 bolt/include/bolt/Profile/YAMLProfileReader.h |  69 ++-
 bolt/lib/Profile/StaleProfileMatching.cpp |  65 ---
 bolt/lib/Profile/YAMLProfileReader.cpp| 110 --
 3 files changed, 119 insertions(+), 125 deletions(-)

diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h 
b/bolt/include/bolt/Profile/YAMLProfileReader.h
index 36e8f8739eee1..e8a34ecad9a08 100644
--- a/bolt/include/bolt/Profile/YAMLProfileReader.h
+++ b/bolt/include/bolt/Profile/YAMLProfileReader.h
@@ -16,6 +16,73 @@
 namespace llvm {
 namespace bolt {
 
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+private:
+  using ValueOffset = Bitfield::Element;
+  using ValueOpcode = Bitfield::Element;
+  using ValueInstr = Bitfield::Element;
+  using ValuePred = Bitfield::Element;
+  using ValueSucc = Bitfield::Element;
+
+public:
+  explicit BlendedBlockHash() {}
+
+  explicit BlendedBlockHash(uint64_t Hash) {
+Offset = Bitfield::get(Hash);
+OpcodeHash = Bitfield::get(Hash);
+InstrHash = Bitfield::get(Hash);
+PredHash = Bitfield::get(Hash);
+SuccHash = Bitfield::get(Hash);
+  }
+
+  /// Combine the blended hash into uint64_t.
+  uint64_t combine() const {
+uint64_t Hash = 0;
+Bitfield::set(Hash, Offset);
+Bitfield::set(Hash, OpcodeHash);
+Bitfield::set(Hash, InstrHash);
+Bitfield::set(Hash, PredHash);
+Bitfield::set(Hash, SuccHash);
+return Hash;
+  }
+
+  /// Compute a distance between two given blended hashes. The smaller the
+  /// distance, the more similar two blocks are. For identical basic blocks,
+  /// the distance is zero.
+  uint64_t distance(const BlendedBlockHash &BBH) const {
+assert(OpcodeHash == BBH.OpcodeHash &&
+   "incorrect blended hash distance computation");
+uint64_t Dist = 0;
+// Account for NeighborHash
+Dist += SuccHash == BBH.SuccHash ? 0 : 1;
+Dist += PredHash == BBH.PredHash ? 0 : 1;
+Dist <<= 16;
+// Account for InstrHash
+Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+Dist <<= 16;
+// Account for Offset
+Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+return Dist;
+  }
+
+  /// The offset of the basic block from the function start.
+  uint16_t Offset{0};
+  /// (Loose) Hash of the basic block instructions, excluding operands.
+  uint16_t OpcodeHash{0};
+  /// (Strong)

[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung updated 
https://github.com/llvm/llvm-project/pull/98125

>From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 10:04:25 -0700
Subject: [PATCH 1/9] Comments

Created using spr 1.3.4
---
 bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp 
b/bolt/lib/Profile/YAMLProfileReader.cpp
index 69ea0899c5f2c..6753337c24ea7 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 
   // Maps binary functions to adjacent functions in the FCG.
   for (const BinaryFunction *CallerBF : BFs) {
-// Add all call targets to the hash map.
 for (const BinaryBasicBlock &BB : CallerBF->blocks()) {
   for (const MCInst &Inst : BB) {
 if (!BC.MIB->isCall(Instr))
@@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Create mapping from neighbor hash to BFs.
+  // Using the constructed adjacent function mapping, creates mapping from
+  // neighbor hash to BFs.
   std::unordered_map>
   NeighborHashToBFs;
   for (const BinaryFunction *BF : BFs) {
@@ -552,12 +552,12 @@ size_t 
YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
 .push_back(BF);
   }
 
-  // TODO: change call anchor PR to have this representation - we need it here
+  // TODO: note, this will be introduced in the matching functions with calls
+  // as anchors pr
   DenseMap
   IdToYAMLBF;
-  // TODO: change call anchor PR to have this representation - we need it here
 
-  // Maps hashes to profiled functions.
+  // Maps YAML functions to adjacent functions in the profile FCG.
   std::unordered_map
   YamlBFToHashes(BFs.size());
@@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Matching YAMLBF with neighbor hashes.
+  // Matches YAMLBF to BFs with neighbor hashes.
   for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
 if (YamlBF.Used)
   continue;

>From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 13:52:05 -0700
Subject: [PATCH 2/9] Moved blended hash definition

Created using spr 1.3.4
---
 bolt/include/bolt/Profile/YAMLProfileReader.h |  69 ++-
 bolt/lib/Profile/StaleProfileMatching.cpp |  65 ---
 bolt/lib/Profile/YAMLProfileReader.cpp| 110 --
 3 files changed, 119 insertions(+), 125 deletions(-)

diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h 
b/bolt/include/bolt/Profile/YAMLProfileReader.h
index 36e8f8739eee1..e8a34ecad9a08 100644
--- a/bolt/include/bolt/Profile/YAMLProfileReader.h
+++ b/bolt/include/bolt/Profile/YAMLProfileReader.h
@@ -16,6 +16,73 @@
 namespace llvm {
 namespace bolt {
 
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+private:
+  using ValueOffset = Bitfield::Element;
+  using ValueOpcode = Bitfield::Element;
+  using ValueInstr = Bitfield::Element;
+  using ValuePred = Bitfield::Element;
+  using ValueSucc = Bitfield::Element;
+
+public:
+  explicit BlendedBlockHash() {}
+
+  explicit BlendedBlockHash(uint64_t Hash) {
+Offset = Bitfield::get(Hash);
+OpcodeHash = Bitfield::get(Hash);
+InstrHash = Bitfield::get(Hash);
+PredHash = Bitfield::get(Hash);
+SuccHash = Bitfield::get(Hash);
+  }
+
+  /// Combine the blended hash into uint64_t.
+  uint64_t combine() const {
+uint64_t Hash = 0;
+Bitfield::set(Hash, Offset);
+Bitfield::set(Hash, OpcodeHash);
+Bitfield::set(Hash, InstrHash);
+Bitfield::set(Hash, PredHash);
+Bitfield::set(Hash, SuccHash);
+return Hash;
+  }
+
+  /// Compute a distance between two given blended hashes. The smaller the
+  /// distance, the more similar two blocks are. For identical basic blocks,
+  /// the distance is zero.
+  uint64_t distance(const BlendedBlockHash &BBH) const {
+assert(OpcodeHash == BBH.OpcodeHash &&
+   "incorrect blended hash distance computation");
+uint64_t Dist = 0;
+// Account for NeighborHash
+Dist += SuccHash == BBH.SuccHash ? 0 : 1;
+Dist += PredHash == BBH.PredHash ? 0 : 1;
+Dist <<= 16;
+// Account for InstrHash
+Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+Dist <<= 16;
+// Account for Offset
+Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+return Dist;
+  }
+
+  /// The offset of the basic block from the function start.
+  uint16_t Offset{0};
+  /// (Loose) Hash of the basic block instructions, excluding operands.
+  uint16_t OpcodeHash{0};
+  /// (Strong)

[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung updated 
https://github.com/llvm/llvm-project/pull/98125

>From cf32a43e7c2b04079c6123fe13df4fb7226d771f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 10:04:25 -0700
Subject: [PATCH 01/10] Comments

Created using spr 1.3.4
---
 bolt/lib/Profile/YAMLProfileReader.cpp | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp 
b/bolt/lib/Profile/YAMLProfileReader.cpp
index 69ea0899c5f2c..6753337c24ea7 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -501,7 +501,6 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 
   // Maps binary functions to adjacent functions in the FCG.
   for (const BinaryFunction *CallerBF : BFs) {
-// Add all call targets to the hash map.
 for (const BinaryBasicBlock &BB : CallerBF->blocks()) {
   for (const MCInst &Inst : BB) {
 if (!BC.MIB->isCall(Instr))
@@ -533,7 +532,8 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Create mapping from neighbor hash to BFs.
+  // Using the constructed adjacent function mapping, creates mapping from
+  // neighbor hash to BFs.
   std::unordered_map>
   NeighborHashToBFs;
   for (const BinaryFunction *BF : BFs) {
@@ -552,12 +552,12 @@ size_t 
YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) {
 .push_back(BF);
   }
 
-  // TODO: change call anchor PR to have this representation - we need it here
+  // TODO: note, this will be introduced in the matching functions with calls
+  // as anchors pr
   DenseMap
   IdToYAMLBF;
-  // TODO: change call anchor PR to have this representation - we need it here
 
-  // Maps hashes to profiled functions.
+  // Maps YAML functions to adjacent functions in the profile FCG.
   std::unordered_map
   YamlBFToHashes(BFs.size());
@@ -590,7 +590,7 @@ size_t YAMLProfileReader::matchWithCallGraph(BinaryContext 
&BC) {
 }
   }
 
-  // Matching YAMLBF with neighbor hashes.
+  // Matches YAMLBF to BFs with neighbor hashes.
   for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) {
 if (YamlBF.Used)
   continue;

>From ee9049fc4bd3d4203c19c9c0982a78ab3b47666f Mon Sep 17 00:00:00 2001
From: shawbyoung 
Date: Tue, 9 Jul 2024 13:52:05 -0700
Subject: [PATCH 02/10] Moved blended hash definition

Created using spr 1.3.4
---
 bolt/include/bolt/Profile/YAMLProfileReader.h |  69 ++-
 bolt/lib/Profile/StaleProfileMatching.cpp |  65 ---
 bolt/lib/Profile/YAMLProfileReader.cpp| 110 --
 3 files changed, 119 insertions(+), 125 deletions(-)

diff --git a/bolt/include/bolt/Profile/YAMLProfileReader.h 
b/bolt/include/bolt/Profile/YAMLProfileReader.h
index 36e8f8739eee1..e8a34ecad9a08 100644
--- a/bolt/include/bolt/Profile/YAMLProfileReader.h
+++ b/bolt/include/bolt/Profile/YAMLProfileReader.h
@@ -16,6 +16,73 @@
 namespace llvm {
 namespace bolt {
 
+/// An object wrapping several components of a basic block hash. The combined
+/// (blended) hash is represented and stored as one uint64_t, while individual
+/// components are of smaller size (e.g., uint16_t or uint8_t).
+struct BlendedBlockHash {
+private:
+  using ValueOffset = Bitfield::Element;
+  using ValueOpcode = Bitfield::Element;
+  using ValueInstr = Bitfield::Element;
+  using ValuePred = Bitfield::Element;
+  using ValueSucc = Bitfield::Element;
+
+public:
+  explicit BlendedBlockHash() {}
+
+  explicit BlendedBlockHash(uint64_t Hash) {
+Offset = Bitfield::get(Hash);
+OpcodeHash = Bitfield::get(Hash);
+InstrHash = Bitfield::get(Hash);
+PredHash = Bitfield::get(Hash);
+SuccHash = Bitfield::get(Hash);
+  }
+
+  /// Combine the blended hash into uint64_t.
+  uint64_t combine() const {
+uint64_t Hash = 0;
+Bitfield::set(Hash, Offset);
+Bitfield::set(Hash, OpcodeHash);
+Bitfield::set(Hash, InstrHash);
+Bitfield::set(Hash, PredHash);
+Bitfield::set(Hash, SuccHash);
+return Hash;
+  }
+
+  /// Compute a distance between two given blended hashes. The smaller the
+  /// distance, the more similar two blocks are. For identical basic blocks,
+  /// the distance is zero.
+  uint64_t distance(const BlendedBlockHash &BBH) const {
+assert(OpcodeHash == BBH.OpcodeHash &&
+   "incorrect blended hash distance computation");
+uint64_t Dist = 0;
+// Account for NeighborHash
+Dist += SuccHash == BBH.SuccHash ? 0 : 1;
+Dist += PredHash == BBH.PredHash ? 0 : 1;
+Dist <<= 16;
+// Account for InstrHash
+Dist += InstrHash == BBH.InstrHash ? 0 : 1;
+Dist <<= 16;
+// Account for Offset
+Dist += (Offset >= BBH.Offset ? Offset - BBH.Offset : BBH.Offset - Offset);
+return Dist;
+  }
+
+  /// The offset of the basic block from the function start.
+  uint16_t Offset{0};
+  /// (Loose) Hash of the basic block instructions, excluding operands.
+  uint16_t OpcodeHash{0};
+  /// (Str

[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung edited 
https://github.com/llvm/llvm-project/pull/98125
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung edited 
https://github.com/llvm/llvm-project/pull/98125
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-11 Thread Shaw Young via llvm-branch-commits

https://github.com/shawbyoung ready_for_review 
https://github.com/llvm/llvm-project/pull/98125
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 9875ee8 - Revert "[safestack] Various Solaris fixes (#98469)"

2024-07-11 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-07-11T13:29:35-07:00
New Revision: 9875ee88f0f4dfe87aa1f89df00115ac796ef561

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

LOG: Revert "[safestack] Various Solaris fixes (#98469)"

This reverts commit 5c205b6f7d82ee88ee5a869d6102c5a6388fb3f0.

Added: 


Modified: 
compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
compiler-rt/lib/safestack/CMakeLists.txt
compiler-rt/lib/safestack/safestack.cpp
compiler-rt/lib/safestack/safestack_platform.h
compiler-rt/test/safestack/lit.cfg.py

Removed: 




diff  --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 02ff92f693810..c8bec41db36e9 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} 
${ARM64} ${RISCV64}
 ${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
 ${LOONGARCH64})
 set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64}
-${HEXAGON} ${LOONGARCH64} ${SPARC} ${SPARCV9})
+${HEXAGON} ${LOONGARCH64})
 set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64}
 ${HEXAGON} ${LOONGARCH64})
 set(ALL_SCUDO_STANDALONE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}

diff  --git a/compiler-rt/lib/safestack/CMakeLists.txt 
b/compiler-rt/lib/safestack/CMakeLists.txt
index 730043eb87cab..316ab69ecfdbe 100644
--- a/compiler-rt/lib/safestack/CMakeLists.txt
+++ b/compiler-rt/lib/safestack/CMakeLists.txt
@@ -14,8 +14,6 @@ foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
 ARCHS ${arch}
 SOURCES ${SAFESTACK_SOURCES}
 $
-OBJECT_LIBS RTSanitizerCommon
-RTSanitizerCommonLibc
 CFLAGS ${SAFESTACK_CFLAGS}
 PARENT_TARGET safestack)
 endforeach()

diff  --git a/compiler-rt/lib/safestack/safestack.cpp 
b/compiler-rt/lib/safestack/safestack.cpp
index f8ef224f45494..0751f3988b9c1 100644
--- a/compiler-rt/lib/safestack/safestack.cpp
+++ b/compiler-rt/lib/safestack/safestack.cpp
@@ -224,17 +224,6 @@ INTERCEPTOR(int, pthread_create, pthread_t *thread,
 pthread_attr_destroy(&tmpattr);
   }
 
-#if SANITIZER_SOLARIS
-  // Solaris pthread_attr_init initializes stacksize to 0 (the default), so
-  // hardcode the actual values as documented in pthread_create(3C).
-  if (size == 0)
-#  if defined(_LP64)
-size = 2 * 1024 * 1024;
-#  else
-size = 1024 * 1024;
-#  endif
-#endif
-
   SFS_CHECK(size);
   size = RoundUpTo(size, kStackAlign);
 

diff  --git a/compiler-rt/lib/safestack/safestack_platform.h 
b/compiler-rt/lib/safestack/safestack_platform.h
index 77eeb9cda6e15..d4b2e2ef7391c 100644
--- a/compiler-rt/lib/safestack/safestack_platform.h
+++ b/compiler-rt/lib/safestack/safestack_platform.h
@@ -17,7 +17,6 @@
 #include "sanitizer_common/sanitizer_platform.h"
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -69,24 +68,6 @@ static void *GetRealLibcAddress(const char *symbol) {
   SFS_CHECK(real_##func);
 #endif
 
-#if SANITIZER_SOLARIS
-#  define _REAL(func) _##func
-#  define DEFINE__REAL(ret_type, func, ...) \
-extern "C" ret_type _REAL(func)(__VA_ARGS__)
-
-#  if !defined(_LP64) && _FILE_OFFSET_BITS == 64
-#define _REAL64(func) _##func##64
-#  else
-#define _REAL64(func) _REAL(func)
-#  endif
-#  define DEFINE__REAL64(ret_type, func, ...) \
-extern "C" ret_type _REAL64(func)(__VA_ARGS__)
-
-DEFINE__REAL64(void *, mmap, void *a, size_t b, int c, int d, int e, off_t f);
-DEFINE__REAL(int, munmap, void *a, size_t b);
-DEFINE__REAL(int, mprotect, void *a, size_t b, int c);
-#endif
-
 using ThreadId = uint64_t;
 
 inline ThreadId GetTid() {
@@ -110,10 +91,11 @@ inline int TgKill(pid_t pid, ThreadId tid, int sig) {
   (void)pid;
   return _REAL(_lwp_kill, tid, sig);
 #elif SANITIZER_SOLARIS
-  (void)pid;
-  errno = thr_kill(tid, sig);
-  // TgKill is expected to return -1 on error, not an errno.
-  return errno != 0 ? -1 : 0;
+#  ifdef SYS_lwp_kill
+  return syscall(SYS_lwp_kill, tid, sig);
+#  else
+  return -1;
+#  endif
 #elif SANITIZER_FREEBSD
   return syscall(SYS_thr_kill2, pid, tid, sig);
 #else
@@ -128,7 +110,8 @@ inline void *Mmap(void *addr, size_t length, int prot, int 
flags, int fd,
 #elif SANITIZER_FREEBSD && (defined(__aarch64__) || defined(__x86_64__))
   return (void *)__syscall(SYS_mmap, addr, length, prot, flags, fd, offset);
 #elif SANITIZER_SOLARIS
-  return _REAL64(mmap)(addr, length, prot, flags, fd, offset);
+  return (void *)(uintptr_t)syscall(SYS_mmap, addr, length, prot, flags, fd,
+offset);
 #else
   return (void *)syscall(SYS_mmap, addr, length, prot, flags, fd, offset);
 #endif
@@ -138,8 +1

[llvm-branch-commits] [compiler-rt] da6d977 - Add comment about dependecy

2024-07-11 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-07-11T13:49:06-07:00
New Revision: da6d977b46989435207f015dd3d6d80fef92430b

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

LOG: Add comment about dependecy

Added: 


Modified: 
compiler-rt/lib/safestack/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/lib/safestack/CMakeLists.txt 
b/compiler-rt/lib/safestack/CMakeLists.txt
index 316ab69ecfdbe..3b2e0e888208b 100644
--- a/compiler-rt/lib/safestack/CMakeLists.txt
+++ b/compiler-rt/lib/safestack/CMakeLists.txt
@@ -14,6 +14,7 @@ foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
 ARCHS ${arch}
 SOURCES ${SAFESTACK_SOURCES}
 $
+# Intentionally does not deppend on sanitizer_common.
 CFLAGS ${SAFESTACK_CFLAGS}
 PARENT_TARGET safestack)
 endforeach()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] 5f61b6d - Update CMakeLists.txt

2024-07-11 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-07-11T13:55:33-07:00
New Revision: 5f61b6db87708a03c16afc22a6fcb410ccf77a25

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

LOG: Update CMakeLists.txt

Added: 


Modified: 
compiler-rt/lib/safestack/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/lib/safestack/CMakeLists.txt 
b/compiler-rt/lib/safestack/CMakeLists.txt
index 3b2e0e888208b..d4f99cb69c9c0 100644
--- a/compiler-rt/lib/safestack/CMakeLists.txt
+++ b/compiler-rt/lib/safestack/CMakeLists.txt
@@ -14,7 +14,9 @@ foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
 ARCHS ${arch}
 SOURCES ${SAFESTACK_SOURCES}
 $
-# Intentionally does not deppend on sanitizer_common.
+# Intentionally does not deppend on sanitizer_common,
+# to keep runtime trivial, and more usable in security
+# sensitive applications.
 CFLAGS ${SAFESTACK_CFLAGS}
 PARENT_TARGET safestack)
 endforeach()



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [compiler-rt] c0ff0d2 - Update CMakeLists.txt

2024-07-11 Thread via llvm-branch-commits

Author: Vitaly Buka
Date: 2024-07-11T13:57:36-07:00
New Revision: c0ff0d2f104a8d7c95feb497f286430137828a3d

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

LOG: Update CMakeLists.txt

Added: 


Modified: 
compiler-rt/lib/safestack/CMakeLists.txt

Removed: 




diff  --git a/compiler-rt/lib/safestack/CMakeLists.txt 
b/compiler-rt/lib/safestack/CMakeLists.txt
index d4f99cb69c9c0..4cff95f546931 100644
--- a/compiler-rt/lib/safestack/CMakeLists.txt
+++ b/compiler-rt/lib/safestack/CMakeLists.txt
@@ -15,7 +15,7 @@ foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
 SOURCES ${SAFESTACK_SOURCES}
 $
 # Intentionally does not deppend on sanitizer_common,
-# to keep runtime trivial, and more usable in security
+# to keep runtime trivial, and acceptable for security
 # sensitive applications.
 CFLAGS ${SAFESTACK_CFLAGS}
 PARENT_TARGET safestack)



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CUDA][HIP] Fix template static member (PR #98544)

2024-07-11 Thread Yaxun Liu via llvm-branch-commits

https://github.com/yxsamliu edited 
https://github.com/llvm/llvm-project/pull/98544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CUDA][HIP] Fix template static member (PR #98544)

2024-07-11 Thread Yaxun Liu via llvm-branch-commits

yxsamliu wrote:

> Looks like this patch includes #98543. You may want to exclude it from the 
> pull request.

done

https://github.com/llvm/llvm-project/pull/98544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [lld] 58efe29 - Revert "[MC] set OpenBSD's ELFOSABI by default (#98158) (#98553)"

2024-07-11 Thread via llvm-branch-commits

Author: John Ericson
Date: 2024-07-11T17:23:05-04:00
New Revision: 58efe298e1561d7b22fb80360b075a7c8ab6e968

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

LOG: Revert "[MC] set OpenBSD's ELFOSABI by default (#98158) (#98553)"

This reverts commit 6bc6f6b0fa8724ac2e6d9d025084a393d4d15694.

Added: 


Modified: 
lld/test/ELF/basic-sparcv9.s
llvm/include/llvm/MC/MCELFObjectWriter.h
llvm/test/MC/ELF/osabi.s

Removed: 




diff  --git a/lld/test/ELF/basic-sparcv9.s b/lld/test/ELF/basic-sparcv9.s
index b2f760f21ab05..af63dc47ae84e 100644
--- a/lld/test/ELF/basic-sparcv9.s
+++ b/lld/test/ELF/basic-sparcv9.s
@@ -17,7 +17,7 @@ _start:
 # CHECK-NEXT: Class: 64-bit (0x2)
 # CHECK-NEXT: DataEncoding: BigEndian (0x2)
 # CHECK-NEXT: FileVersion: 1
-# CHECK-NEXT: OS/ABI: OpenBSD (0x0)
+# CHECK-NEXT: OS/ABI: SystemV (0x0)
 # CHECK-NEXT: ABIVersion: 0
 # CHECK-NEXT: Unused: (00 00 00 00 00 00 00)
 # CHECK-NEXT:   }

diff  --git a/llvm/include/llvm/MC/MCELFObjectWriter.h 
b/llvm/include/llvm/MC/MCELFObjectWriter.h
index 12237094ad86a..d7c223cdcc07f 100644
--- a/llvm/include/llvm/MC/MCELFObjectWriter.h
+++ b/llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -78,8 +78,6 @@ class MCELFObjectTargetWriter : public MCObjectTargetWriter {
 return ELF::ELFOSABI_FREEBSD;
   case Triple::Solaris:
 return ELF::ELFOSABI_SOLARIS;
-  case Triple::OpenBSD:
-return ELF::ELFOSABI_OPENBSD;
   default:
 return ELF::ELFOSABI_NONE;
 }

diff  --git a/llvm/test/MC/ELF/osabi.s b/llvm/test/MC/ELF/osabi.s
index 44912f4987c11..dc6ad2a349d75 100644
--- a/llvm/test/MC/ELF/osabi.s
+++ b/llvm/test/MC/ELF/osabi.s
@@ -10,7 +10,3 @@
 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-freebsd %s | llvm-readobj 
-h - | \
 # RUN:   FileCheck %s --check-prefix=FREEBSD
 # FREEBSD: OS/ABI: FreeBSD
-
-# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-openbsd %s | llvm-readobj 
-h - | \
-# RUN:   FileCheck %s --check-prefix=OPENBSD
-# OPENBSD: OS/ABI: OpenBSD



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [mlir] [mlir][linalg] Implement TilingInterface for winograd operators (PR #96184)

2024-07-11 Thread via llvm-branch-commits

MaheshRavishankar wrote:

> I think @MaheshRavishankar should take a look at the interface implementation 
> details.

Actually @Max191 or @harsh-nod  have most context on the interface 
implementation details. I actually dont care as much as long as it isnt 
changing the interface implementation details. I wont be able to do a detailed 
review for this, but if there is a specific issue that seems off, please 
upsignal.

https://github.com/llvm/llvm-project/pull/96184
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][asan] Use %p to print addresses (PR #98575)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/98575

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][hwasan] Use %p to print addresses (PR #98576)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/98576

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][memprof] Use %p to print addresses (PR #98577)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/98577

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka created 
https://github.com/llvm/llvm-project/pull/98578

None


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][asan] Use %p to print addresses (PR #98575)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/98575.diff


2 Files Affected:

- (modified) compiler-rt/lib/asan/asan_descriptions.cpp (+1-1) 
- (modified) compiler-rt/lib/asan/asan_rtl.cpp (+1-1) 


``diff
diff --git a/compiler-rt/lib/asan/asan_descriptions.cpp 
b/compiler-rt/lib/asan/asan_descriptions.cpp
index 05a277cfa0a84..1c2f20a76343b 100644
--- a/compiler-rt/lib/asan/asan_descriptions.cpp
+++ b/compiler-rt/lib/asan/asan_descriptions.cpp
@@ -292,7 +292,7 @@ static void DescribeAddressRelativeToGlobal(uptr addr, uptr 
access_size,
   str.AppendF(" global variable '%s' defined in '",
   MaybeDemangleGlobalName(g.name));
   PrintGlobalLocation(&str, g, /*print_module_name=*/false);
-  str.AppendF("' (0x%zx) of size %zu\n", g.beg, g.size);
+  str.AppendF("' (%p) of size %zu\n", (void *)g.beg, g.size);
   str.Append(d.Default());
   PrintGlobalNameIfASCII(&str, g);
   Printf("%s", str.data());
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp 
b/compiler-rt/lib/asan/asan_rtl.cpp
index c484e086a5ef7..d42a75e9e5211 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -382,7 +382,7 @@ void PrintAddressSpaceLayout() {
 
   Printf("SHADOW_SCALE: %d\n", (int)ASAN_SHADOW_SCALE);
   Printf("SHADOW_GRANULARITY: %d\n", (int)ASAN_SHADOW_GRANULARITY);
-  Printf("SHADOW_OFFSET: 0x%zx\n", (uptr)ASAN_SHADOW_OFFSET);
+  Printf("SHADOW_OFFSET: %p\n", (void *)ASAN_SHADOW_OFFSET);
   CHECK(ASAN_SHADOW_SCALE >= 3 && ASAN_SHADOW_SCALE <= 7);
   if (kMidMemBeg)
 CHECK(kMidShadowBeg > kLowShadowEnd &&

``




https://github.com/llvm/llvm-project/pull/98575
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][hwasan] Use %p to print addresses (PR #98576)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/98576.diff


1 Files Affected:

- (modified) compiler-rt/lib/hwasan/hwasan_report.cpp (+1-2) 


``diff
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp 
b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 9fbf38ae6a1f4..503784b6c4532 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -328,8 +328,7 @@ static void PrintStackAllocations(const 
StackAllocationsRingBuffer *sa,
   break;
 uptr pc_mask = (1ULL << 48) - 1;
 uptr pc = record & pc_mask;
-frame_desc.AppendF("  record_addr:0x%zx record:0x%zx",
-   reinterpret_cast(record_addr), record);
+frame_desc.AppendF("  record_addr:%p record:0x%zx", record_addr, record);
 SymbolizedStackHolder symbolized_stack(
 Symbolizer::GetOrInit()->SymbolizePC(pc));
 const SymbolizedStack *frame = symbolized_stack.get();

``




https://github.com/llvm/llvm-project/pull/98576
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][memprof] Use %p to print addresses (PR #98577)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/98577.diff


1 Files Affected:

- (modified) compiler-rt/lib/memprof/memprof_rtl.cpp (+1-1) 


``diff
diff --git a/compiler-rt/lib/memprof/memprof_rtl.cpp 
b/compiler-rt/lib/memprof/memprof_rtl.cpp
index a87e8cefd6c40..cf4bde808bfad 100644
--- a/compiler-rt/lib/memprof/memprof_rtl.cpp
+++ b/compiler-rt/lib/memprof/memprof_rtl.cpp
@@ -152,7 +152,7 @@ void PrintAddressSpaceLayout() {
 
   Printf("SHADOW_SCALE: %d\n", (int)SHADOW_SCALE);
   Printf("SHADOW_GRANULARITY: %d\n", (int)SHADOW_GRANULARITY);
-  Printf("SHADOW_OFFSET: 0x%zx\n", (uptr)SHADOW_OFFSET);
+  Printf("SHADOW_OFFSET: %p\n", (void *)SHADOW_OFFSET);
   CHECK(SHADOW_SCALE >= 3 && SHADOW_SCALE <= 7);
 }
 

``




https://github.com/llvm/llvm-project/pull/98577
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread via llvm-branch-commits

llvmbot wrote:




@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/98578.diff


12 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h 
(+2-2) 
- (modified) 
compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp (+2-1) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp (+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp (+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp 
(+4-3) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp 
(+1-1) 
- (modified) 
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp 
(+2-2) 
- (modified) 
compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp 
(+2-2) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_tls_get_addr.cpp (+7-7) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_win.cpp (+4-4) 
- (modified) 
compiler-rt/lib/sanitizer_common/tests/sanitizer_stacktrace_test.cpp (+1-1) 


``diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h 
b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
index 6e73065d7f53c..cdc0e0921449b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h
@@ -316,13 +316,13 @@ class SizeClassAllocator64 {
 Printf(
 "%s %02zd (%6zd): mapped: %6zdK allocs: %7zd frees: %7zd inuse: %6zd "
 "num_freed_chunks %7zd avail: %6zd rss: %6zdK releases: %6zd "
-"last released: %6lldK region: 0x%zx\n",
+"last released: %6lldK region: %p\n",
 region->exhausted ? "F" : " ", class_id, ClassIdToSize(class_id),
 region->mapped_user >> 10, region->stats.n_allocated,
 region->stats.n_freed, in_use, region->num_freed_chunks, avail_chunks,
 rss >> 10, region->rtoi.num_releases,
 region->rtoi.last_released_bytes >> 10,
-SpaceBeg() + kRegionSize * class_id);
+(void *)(SpaceBeg() + kRegionSize * class_id));
   }
 
   void PrintStats() {
diff --git 
a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
index ce4326967180d..506659a58c45e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cpp
@@ -75,7 +75,8 @@ static void SanitizerDumpCoverage(const uptr* unsorted_pcs, 
uptr len) {
 if (!pc) continue;
 
 if (!GetModuleAndOffsetForPc(pc, nullptr, 0, &pcs[i])) {
-  Printf("ERROR: unknown pc 0x%zx (may happen if dlclose is used)\n", pc);
+  Printf("ERROR: unknown pc %p (may happen if dlclose is used)\n",
+ (void*)pc);
   continue;
 }
 uptr module_base = pc - pcs[i];
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp
index b7fc9444cc66b..f0e1e3d69def5 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp
@@ -105,8 +105,8 @@ void LibIgnore::OnLibraryLoaded(const char *name) {
   continue;
 if (IsPcInstrumented(range.beg) && IsPcInstrumented(range.end - 1))
   continue;
-VReport(1, "Adding instrumented range 0x%zx-0x%zx from library '%s'\n",
-range.beg, range.end, mod.full_name());
+VReport(1, "Adding instrumented range %p-%p from library '%s'\n",
+(void *)range.beg, (void *)range.end, mod.full_name());
 const uptr idx =
 atomic_load(&instrumented_ranges_count_, memory_order_relaxed);
 CHECK_LT(idx, ARRAY_SIZE(instrumented_code_ranges_));
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index cbdf3e95925bf..8ebe37d649415 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -1372,8 +1372,8 @@ void DumpProcessMap() {
   for (uptr i = 0; i < modules.size(); ++i) {
 char uuid_str[128];
 FormatUUID(uuid_str, sizeof(uuid_str), modules[i].uuid());
-Printf("0x%zx-0x%zx %s (%s) %s\n", modules[i].base_address(),
-   modules[i].max_address(), modules[i].full_name(),
+Printf("%p-%p %s (%s) %s\n", (void *)modules[i].base_address(),
+   (void *)modules[i].max_address(), modules[i].full_name(),
ModuleArchToString(modules[i].arch()), uuid_str);
   }
   Printf("End of module map.\n");
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp 
b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp
index 969327a7a0fbe..7d7d57543

[llvm-branch-commits] [clang] [CUDA][HIP] Fix template static member (PR #98544)

2024-07-11 Thread Yaxun Liu via llvm-branch-commits

https://github.com/yxsamliu closed 
https://github.com/llvm/llvm-project/pull/98544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][memprof] Use %p to print addresses (PR #98577)

2024-07-11 Thread Teresa Johnson via llvm-branch-commits

https://github.com/teresajohnson approved this pull request.


https://github.com/llvm/llvm-project/pull/98577
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [CUDA][HIP] Fix template static member (PR #98544)

2024-07-11 Thread Yaxun Liu via llvm-branch-commits

yxsamliu wrote:

I thought this PR will merge to main branch, but it only merges to my own 
branch. I have to open another PR to merge it to main branch.

https://github.com/llvm/llvm-project/pull/98544
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][asan] Use %p to print addresses (PR #98575)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98575


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][asan] Use %p to print addresses (PR #98575)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98575


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][hwasan] Use %p to print addresses (PR #98576)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98576


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][hwasan] Use %p to print addresses (PR #98576)

2024-07-11 Thread Thurston Dang via llvm-branch-commits

https://github.com/thurstond approved this pull request.


https://github.com/llvm/llvm-project/pull/98576
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Thurston Dang via llvm-branch-commits

https://github.com/thurstond approved this pull request.


https://github.com/llvm/llvm-project/pull/98578
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98578


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98578


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98578


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [NFC][sanitizer_common] Use %p to print addresses (PR #98578)

2024-07-11 Thread Vitaly Buka via llvm-branch-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/98578


___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT][docs] Expand Heatmaps.md (PR #98162)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis edited 
https://github.com/llvm/llvm-project/pull/98162
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [BOLT][docs] Expand Heatmaps.md (PR #98162)

2024-07-11 Thread Paschalis Mpeis via llvm-branch-commits

https://github.com/paschalis-mpeis edited 
https://github.com/llvm/llvm-project/pull/98162
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits