[PATCH] D103131: support debug info for alias variable

2021-05-25 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4948
 
+void CGDebugInfo::EmitGlobalAlias(llvm::GlobalAlias *Var, const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())

Var is never used in the EmitGlobalAlias ,we don't need the same.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4929
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().hasReducedDebugInfo())
+DI->EmitGlobalAlias(GA, VD);

this should be other way right  i.e if(!getCodeGenOpts().hasReducedDebugInfo())


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103131/new/

https://reviews.llvm.org/D103131

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


[PATCH] D103131: support debug info for alias variable

2021-05-26 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4949
+void CGDebugInfo::EmitGlobalAlias(llvm::GlobalAlias *Var, const VarDecl *D) {
+  if (!CGM.getCodeGenOpts().hasReducedDebugInfo())
+return;

check is redundant ,no required here the caller takencare the check .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103131/new/

https://reviews.llvm.org/D103131

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


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-30 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 created this revision.
umesh.kalappa0 added a reviewer: nikic.
umesh.kalappa0 added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
umesh.kalappa0 requested review of this revision.
Herald added a project: clang.
Herald added subscribers: llvm-commits, cfe-commits.

Fix for the issue :https://github.com/llvm/llvm-project/issues/59580

Where we don't emit the inbounds flag for the GEP when wrapv is enbled .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142872

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/inbounds.c
  llvm/include/llvm/IR/ConstantFold.h
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp

Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -2510,7 +2510,9 @@
 ArgVec.push_back(Idx);
   }
 
-  unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
+  unsigned SubClassOptionalData = ( InBounds && !llvm::getSignedWrap() ) ?
+	   GEPOperator::IsInBounds : 0;
+
   if (InRangeIndex && *InRangeIndex < 63)
 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
   const ConstantExprKeyType Key(Instruction::GetElementPtr, ArgVec, 0,
Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool SignedWrap) {
+  llvm::SignedWrap=SignedWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s | FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1689,6 +1689,9 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  if (Args.hasArg(OPT_fwrapv))
+Opts.SignedWrap = true;
+
   if (!Opts.EnableDIPreservationVerify && Opts.DIBugsReportFilePath.size()) {
 Diags.Report(diag::warn_ignoring_verify_debuginfo_preserve_export)
 << Opts.DIBugsReportFilePath;
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,12 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
+
+if (CGM.getCodeGenOpts().SignedWrap)
+  llvm::setSignedWrap(true);
+
 Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
   }
 
   // The result of this decay conversion points to an array element within the
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -27,6 +27,7 @@
 CODEGENOPT(Name, Bits, Default)
 #endif
 
+CODEGENOPT(SignedWrap	 , 1, 0) ///< -fwarpv
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
 ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
 llvm::DebugCompressionType::None)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-30 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 updated this revision to Diff 493282.
umesh.kalappa0 edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/inbounds.c
  llvm/include/llvm/IR/ConstantFold.h
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp


Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -2510,7 +2510,9 @@
 ArgVec.push_back(Idx);
   }
 
-  unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
+  unsigned SubClassOptionalData = ( InBounds && !llvm::getSignedWrap() ) ?
+  GEPOperator::IsInBounds : 0;
+
   if (InRangeIndex && *InRangeIndex < 63)
 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
   const ConstantExprKeyType Key(Instruction::GetElementPtr, ArgVec, 0,
Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool SignedWrap) {
+  llvm::SignedWrap=SignedWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s 
| FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,12 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
+
+if (getLangOpts().isSignedOverflowDefined())
+  llvm::setSignedWrap(true);
+
 Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
   }
 
   // The result of this decay conversion points to an array element within the


Index: llvm/lib/IR/Constants.cpp
===
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -2510,7 +2510,9 @@
 ArgVec.push_back(Idx);
   }
 
-  unsigned SubClassOptionalData = InBounds ? GEPOperator::IsInBounds : 0;
+  unsigned SubClassOptionalData = ( InBounds && !llvm::getSignedWrap() ) ?
+	   GEPOperator::IsInBounds : 0;
+
   if (InRangeIndex && *InRangeIndex < 63)
 SubClassOptionalData |= (*InRangeIndex + 1) << 1;
   const ConstantExprKeyType Key(Instruction::GetElementPtr, ArgVec, 0,
Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool SignedWrap) {
+  llvm::SignedWrap=SignedWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s | FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret 

[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-30 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

In D142872#4090317 , @nikic wrote:

> You also shouldn't need to introduce any new handling for the fwrapv option. 
> I'm not sure how exactly it is currently threaded through, but there must be 
> existing handling for it already. For example, there is 
> isSignedOverflowDefined() on LangOptions.

Make sense here .


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

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


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-30 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

In D142872#4090304 , @nikic wrote:

> CreateConstArrayGEP currently always creates an inbounds GEP. You need to 
> modify it make inbounds optional or use a different method, not suppress it 
> in the constant folding infrastructure.

Thank you very much for the feedback and

We tried calling other overload like "CreateConstGEP" ,but that didn't help due 
to  below call from "ConstantFoldGetElementPtr" ,that was recursive call from   
"ConstantExpr::getGetElementPtr" .

>> return ConstantExpr::getGetElementPtr(PointeeTy, C, Idxs, /*InBounds=*/true, 
>> InRangeIndex);

So we thought of disabling the call like "ConstantExpr::getGetElementPtr"  with 
InBounds=true  for wrapv and changes  has its consensus so we end up changes 
that is shared  for review.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

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


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-31 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 updated this revision to Diff 493612.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/inbounds.c
  llvm/include/llvm/IR/ConstantFold.h
  llvm/lib/IR/ConstantFold.cpp


Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool sWrap) {
+  llvm::SignedWrap=sWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s 
| FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,16 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
-Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
+if (getLangOpts().isSignedOverflowDefined()) {
+  llvm::setSignedWrap(true);
+  llvm::dbgs()<<"Test\n";
+  Addr = Builder.CreateConstGEP(Addr, 0, "arraydecay");
+}
+else {
+  Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+}
+
   }
 
   // The result of this decay conversion points to an array element within the


Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool sWrap) {
+  llvm::SignedWrap=sWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s | FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,16 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
-Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
+if (getLangOpts().isSignedOverflowDefined()) {
+  llvm::setSignedWrap(true);
+  llvm::dbgs()<<"Test\n";
+  Addr = Builder.CreateConstGEP(Addr, 0, "arraydecay");
+}
+else {
+  Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+}
+
   }
 
   // The result of this decay conversion points to an array element within the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-31 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

In D142872#4093093 , @nikic wrote:

> @umesh.kalappa0 This issue should be fixed by 
> https://github.com/llvm/llvm-project/commit/5f01a626dd0615df49773d419c75aeb33666ee83.
>  Can you please give it another try?

Thank you @nikic  for the quick changes ,and updated the review


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

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


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-31 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 updated this revision to Diff 493623.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/inbounds.c
  llvm/include/llvm/IR/ConstantFold.h
  llvm/lib/IR/ConstantFold.cpp


Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool sWrap) {
+  llvm::SignedWrap=sWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s 
| FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,15 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
-Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
+if (getLangOpts().isSignedOverflowDefined()) {
+  llvm::setSignedWrap(true);
+  Addr = Builder.CreateConstGEP(Addr, 0, "arraydecay");
+}
+else {
+  Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+}
+
   }
 
   // The result of this decay conversion points to an array element within the


Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -347,6 +347,14 @@
   }
 }
 
+bool llvm::getSignedWrap() {
+  return llvm::SignedWrap;
+}
+
+void llvm::setSignedWrap(bool sWrap) {
+  llvm::SignedWrap=sWrap;
+}
+
 Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
 Type *DestTy) {
   if (isa(V))
Index: llvm/include/llvm/IR/ConstantFold.h
===
--- llvm/include/llvm/IR/ConstantFold.h
+++ llvm/include/llvm/IR/ConstantFold.h
@@ -26,10 +26,15 @@
 
 namespace llvm {
   template  class ArrayRef;
+  inline bool SignedWrap = false;
+
   class Value;
   class Constant;
   class Type;
 
+  bool getSignedWrap(void);
+  void setSignedWrap(bool Wrap);
+
   // Constant fold various types of instruction...
   Constant *ConstantFoldCastInstruction(
 unsigned opcode, ///< The opcode of the cast
Index: clang/test/CodeGen/inbounds.c
===
--- /dev/null
+++ clang/test/CodeGen/inbounds.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fwrapv -emit-llvm -o - %s | FileCheck %s 
+
+extern char base[];
+
+char *test() {
+return base + 1;
+}
+
+// CHECK: ret ptr getelementptr   (i8, ptr @base, i64 1)
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3613,7 +3613,15 @@
   if (!E->getType()->isVariableArrayType()) {
 assert(isa(Addr.getElementType()) &&
"Expected pointer to array");
-Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+
+if (getLangOpts().isSignedOverflowDefined()) {
+  llvm::setSignedWrap(true);
+  Addr = Builder.CreateConstGEP(Addr, 0, "arraydecay");
+}
+else {
+  Addr = Builder.CreateConstArrayGEP(Addr, 0, "arraydecay");
+}
+
   }
 
   // The result of this decay conversion points to an array element within the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142872: Honor the fwrapv option when generating the inbounds GEP .

2023-01-31 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

@nikic ,is that changes are ok ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142872/new/

https://reviews.llvm.org/D142872

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


[PATCH] D70696: [DebugInfo] Support to emit debugInfo for extern variables

2019-11-30 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

@SouraVX  and @yonghong-song

cat extern.c 
int global_var = 2;

compile as an extern.c shared a library ,then final executable a.out doesn't 
have debugInfo for global_var.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70696/new/

https://reviews.llvm.org/D70696



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


[PATCH] D146942: PowerPC ABI incompatibility with GNU on complex arguments

2023-03-27 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 created this revision.
umesh.kalappa0 added a reviewer: nikic.
umesh.kalappa0 added projects: LLVM, clang.
Herald added subscribers: StephenFan, shchenz, nemanjai.
Herald added a project: All.
umesh.kalappa0 requested review of this revision.
Herald added a subscriber: cfe-commits.

Changes : Like GNU GCC passes and returns float/double/long double  complex in 
FPRs .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146942

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4720,6 +4720,7 @@
 IsRetSmallStructInRegABI(RetSmallStructInRegABI) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
 if (!getCXXABI().classifyReturnType(FI))
@@ -4776,6 +4777,15 @@
   return CharUnits::fromQuantity(4);
 }
 
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (Ty->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
+  return DefaultABIInfo::classifyArgumentType(Ty);
+}
+
 ABIArgInfo PPC32_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
   uint64_t Size;
 
@@ -4801,6 +4811,9 @@
 }
   }
 
+  if (RetTy->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
   return DefaultABIInfo::classifyReturnType(RetTy);
 }
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4720,6 +4720,7 @@
 IsRetSmallStructInRegABI(RetSmallStructInRegABI) {}
 
   ABIArgInfo classifyReturnType(QualType RetTy) const;
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
 if (!getCXXABI().classifyReturnType(FI))
@@ -4776,6 +4777,15 @@
   return CharUnits::fromQuantity(4);
 }
 
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if (Ty->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
+  return DefaultABIInfo::classifyArgumentType(Ty);
+}
+
 ABIArgInfo PPC32_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
   uint64_t Size;
 
@@ -4801,6 +4811,9 @@
 }
   }
 
+  if (RetTy->isAnyComplexType())
+return ABIArgInfo::getDirect();
+
   return DefaultABIInfo::classifyReturnType(RetTy);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108421: Mark openmp internal global dso_local

2021-09-02 Thread Umesh Kalappa via Phabricator via cfe-commits
umesh.kalappa0 added a comment.

In D108421#2977216 , @MaskRay wrote:

> In D108421#2977107 , @kamleshbhalui 
> wrote:
>
>> In D108421#2958848 , @MaskRay 
>> wrote:
>>
>>> If you read the comment in TargetMachine::shouldAssumeDSOLocal: this is the 
>>> wrong direction. dso_local is assumed to be marked by the frontend.
>>>
>>> Direct accesses and GOT accesses are trade-offs. Direct accesses are not 
>>> always preferred. The MachO special case is an unfortunate case for their 
>>> xnu kernel, not a good example here.
>>
>> @MaskRay I would like to know more about these trade-offs details, any 
>> supporting documents will do.
>> Considering below testcase, can you shed some light how code generated by 
>> llc-12 is better than llc-11 for given testcase?
>> https://godbolt.org/z/x9xojWb58
>
> This is a very minor issue. First, global variable access is rarely a 
> performance bottleneck.
> Second, if the symbol turns out to be non-preemptible (which implies that it 
> is defined in the component), the R_X86_64_REX_GOTPCRELX GOT indirection can 
> be optimized out.
> The only minor issue is slightly longer code sequence.
>
>> And FYI this testcase does not work when build as Linux Kernel Module. LKM 
>> loader throw error("Unknown rela relocation: 42")?
>
> This is a kernel issue. Please mention the justification (is it related to 
> OpenMP?) in the first place.
> The kernel can be compiled in -fpie mode. In this mode, taking the address of 
> a default-visibility undefined symbol uses R_X86_64_REX_GOTPCRELX.
> So the kernel should support R_X86_64_REX_GOTPCRELX anyway.
>
> ---
>
> If we think the optimization is meaningful:
>
> Depending on the property of `.gomp_critical_user_.atomic_reduction.var` 
> different DSOLocal strategies should be used.
> If it is TU-local, make it local linkage. If it is linked image local, make 
> it hidden visibility.
> If it may be defined in a shared object and shared with other shared objects 
> or the main executable, (not so sure because such symbol interposition does 
> not work in other binary formats), use dso_preemptable as is.
>
> I believe the current forced dso_local is definitely incorrect because it may 
> break `-fpic -shared` links.

@kamleshbhalui  ,make the changes accordingly that honour -fpic and don't mark 
dsolocal in this case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108421/new/

https://reviews.llvm.org/D108421

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