[PATCH] D136737: [Draft] [clang] Add builtin_unspecified_value

Juneyoung Lee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 22:37:02 PDT 2022


aqjune created this revision.
Herald added subscribers: steakhal, martong, arphaman.
Herald added a reviewer: shafik.
Herald added a reviewer: NoQ.
Herald added a project: All.
aqjune requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds a builtin constant that lowers to `freeze(poison)`.
This is necessary to patch the intrinsics like e.g., `mm256_castsi128_si256` to be lowered to the following sequence:

  %a1 = freeze <2 x double> poison // <- would like to represent this as '__builtin_unspecified_value' in C/C++.
  %res = shufflevector <2 x double> %a0, <2 x double> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>

Currently it is being lowered to:

  %res = shufflevector <2x  double> %a0, undef, <4 x i32> <i32 0, i32 1, i32 -1, i32 -1>

The current lowering may incorrectly introduce undefined behavior.

A related, previous patch was here: https://reviews.llvm.org/D130339


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136737

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/tools/libclang/CXCursor.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136737.470713.patch
Type: text/x-patch
Size: 9935 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221026/1ca15f5f/attachment.bin>


More information about the cfe-commits mailing list