Skip to content

Commit 2f0d6c5

Browse files
Extract More Information from Debug Info (#742)
* Expose getDILocation() * expose getSrcCodeFromIR for DebugLocation + minor * Remove some unused includes * Fix AliasInfo * better fallback handling for getDebugLocation, etc * Disable failing test and refer to tracking issue #741 * fix unittests compiler version check --------- Co-authored-by: Sriteja Kummita <38907381+sritejakv@users.noreply.github.com> Co-authored-by: Sriteja Kummita <sriteja.ku@gmail.com>
1 parent 2c111b5 commit 2f0d6c5

File tree

23 files changed

+111
-92
lines changed

23 files changed

+111
-92
lines changed

cmake/phasar_macros.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ function(generate_ll_file)
161161

162162
string(REGEX MATCH "clang\\+*-?[0-9]*$" compiler "${CMAKE_CXX_COMPILER}")
163163
if (compiler)
164-
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
164+
if(PHASAR_LLVM_VERSION GREATER_EQUAL 15)
165165
list(APPEND GEN_CXX_FLAGS -Xclang -no-opaque-pointers)
166166
endif()
167-
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
167+
168+
if(PHASAR_LLVM_VERSION GREATER_EQUAL 15)
168169
list(APPEND GEN_C_FLAGS -Xclang -no-opaque-pointers)
169170
endif()
170171
endif()

include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_
1111
#define PHASAR_DATAFLOW_IFDSIDE_IDETABULATIONPROBLEM_H_
1212

13-
#include "phasar/ControlFlow/ICFGBase.h"
1413
#include "phasar/DB/ProjectIRDBBase.h"
1514
#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
1615
#include "phasar/DataFlow/IfdsIde/EdgeFunctions.h"
@@ -22,15 +21,10 @@
2221
#include "phasar/DataFlow/IfdsIde/SolverResults.h"
2322
#include "phasar/Utils/JoinLattice.h"
2423
#include "phasar/Utils/NullAnalysisPrinter.h"
25-
#include "phasar/Utils/Printer.h"
2624
#include "phasar/Utils/SemiRing.h"
2725
#include "phasar/Utils/Soundness.h"
2826

29-
#include "llvm/ADT/StringRef.h"
30-
3127
#include <cassert>
32-
#include <functional>
33-
#include <memory>
3428
#include <optional>
3529
#include <set>
3630
#include <string>

include/phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h"
1414
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
1515
#include "phasar/Domain/AnalysisDomain.h"
16-
#include "phasar/Domain/BinaryDomain.h"
1716

1817
#include <set>
1918
#include <string>

include/phasar/DataFlow/PathSensitivity/PathSensitivityManagerBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include "phasar/Utils/Logger.h"
1515
#include "phasar/Utils/Utilities.h"
1616

17+
#include "llvm/ADT/BitVector.h"
1718
#include "llvm/ADT/DenseSet.h"
18-
#include "llvm/ADT/IntEqClasses.h"
1919
#include "llvm/ADT/SmallVector.h"
2020

2121
namespace llvm {

include/phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFlowFunctions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "phasar/DataFlow/IfdsIde/FlowFunctions.h"
1414
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h"
1515
#include "phasar/PhasarLLVM/Utils/LLVMShorthands.h"
16-
#include "phasar/Utils/TypeTraits.h"
1716

1817
#include "llvm/ADT/PointerIntPair.h"
1918
#include "llvm/IR/Constant.h"
@@ -30,7 +29,6 @@
3029
#include <set>
3130
#include <type_traits>
3231
#include <utility>
33-
#include <vector>
3432

3533
namespace psr {
3634

include/phasar/PhasarLLVM/DataFlow/IfdsIde/Problems/IDETypeStateAnalysis.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@
1515
#include "phasar/DataFlow/IfdsIde/FlowFunctions.h"
1616
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
1717
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedCFG.h"
18-
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFlowFunctions.h"
1918
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMZeroValue.h"
2019
#include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h"
2120
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"
22-
#include "phasar/PhasarLLVM/Utils/DataFlowAnalysisType.h"
23-
#include "phasar/Utils/ByRef.h"
2421
#include "phasar/Utils/JoinLattice.h"
2522
#include "phasar/Utils/Logger.h"
2623
#include "phasar/Utils/Printer.h"
27-
#include "phasar/Utils/TypeTraits.h"
2824

2925
#include "llvm/ADT/StringRef.h"
3026
#include "llvm/Demangle/Demangle.h"
3127
#include "llvm/IR/Function.h"
32-
#include "llvm/IR/Instruction.h"
3328
#include "llvm/IR/Instructions.h"
3429
#include "llvm/IR/Value.h"
3530

36-
#include <memory>
3731
#include <set>
3832
#include <string>
3933
#include <type_traits>

include/phasar/PhasarLLVM/Utils/LLVMIRToSrc.h

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,37 @@ class Value;
3131
class GlobalVariable;
3232
class Module;
3333
class DIFile;
34+
class DILocation;
3435
} // namespace llvm
3536

3637
namespace psr {
38+
struct DebugLocation {
39+
unsigned Line{};
40+
unsigned Column{};
41+
const llvm::DIFile *File{};
42+
};
43+
44+
struct SourceCodeInfo {
45+
std::string SourceCodeLine;
46+
std::string SourceCodeFilename;
47+
std::string SourceCodeFunctionName;
48+
unsigned Line = 0;
49+
unsigned Column = 0;
50+
51+
[[nodiscard]] bool empty() const noexcept;
52+
53+
[[nodiscard]] bool operator==(const SourceCodeInfo &Other) const noexcept;
54+
[[nodiscard]] inline bool
55+
operator!=(const SourceCodeInfo &Other) const noexcept {
56+
return !(*this == Other);
57+
}
58+
59+
/// Similar to operator==, but takes different SourceCodeFileName locations
60+
/// into account
61+
[[nodiscard]] bool equivalentWith(const SourceCodeInfo &Other) const;
62+
};
63+
64+
[[nodiscard]] llvm::DILocation *getDILocation(const llvm::Value *V);
3765

3866
[[nodiscard]] std::string getVarNameFromIR(const llvm::Value *V);
3967

@@ -55,29 +83,10 @@ getLineAndColFromIR(const llvm::Value *V);
5583

5684
[[nodiscard]] std::string getSrcCodeFromIR(const llvm::Value *V,
5785
bool Trim = true);
86+
[[nodiscard]] std::string getSrcCodeFromIR(DebugLocation Loc, bool Trim = true);
5887

5988
[[nodiscard]] std::string getModuleIDFromIR(const llvm::Value *V);
6089

61-
struct SourceCodeInfo {
62-
std::string SourceCodeLine;
63-
std::string SourceCodeFilename;
64-
std::string SourceCodeFunctionName;
65-
unsigned Line = 0;
66-
unsigned Column = 0;
67-
68-
[[nodiscard]] bool empty() const noexcept;
69-
70-
[[nodiscard]] bool operator==(const SourceCodeInfo &Other) const noexcept;
71-
[[nodiscard]] inline bool
72-
operator!=(const SourceCodeInfo &Other) const noexcept {
73-
return !(*this == Other);
74-
}
75-
76-
/// Similar to operator==, but takes different SourceCodeFileName locations
77-
/// into account
78-
[[nodiscard]] bool equivalentWith(const SourceCodeInfo &Other) const;
79-
};
80-
8190
/// Used from the JSON library internally to implicitly convert between json and
8291
/// SourceCodeInfo
8392
void from_json(const nlohmann::json &J, SourceCodeInfo &Info);
@@ -87,12 +96,6 @@ void to_json(nlohmann::json &J, const SourceCodeInfo &Info);
8796

8897
[[nodiscard]] SourceCodeInfo getSrcCodeInfoFromIR(const llvm::Value *V);
8998

90-
struct DebugLocation {
91-
unsigned Line{};
92-
unsigned Column{};
93-
const llvm::DIFile *File{};
94-
};
95-
9699
[[nodiscard]] std::optional<DebugLocation>
97100
getDebugLocation(const llvm::Value *V);
98101

include/phasar/Pointer/AliasInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "phasar/Pointer/AliasResult.h"
1515
#include "phasar/Utils/AnalysisProperties.h"
1616
#include "phasar/Utils/ByRef.h"
17+
#include "phasar/Utils/TypeTraits.h"
1718

1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/ADT/Twine.h"

include/phasar/Pointer/AliasInfoBase.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
#define PHASAR_POINTER_ALIASINFOBASE_H
1212

1313
#include "phasar/Pointer/AliasInfoTraits.h"
14-
#include "phasar/Utils/TypeTraits.h"
14+
#include "phasar/Utils/Macros.h"
1515

16-
#include "llvm/ADT/DenseSet.h"
1716
#include "llvm/Support/raw_ostream.h"
1817

19-
#include "nlohmann/json.hpp"
18+
#include "nlohmann/json_fwd.hpp"
2019

2120
#include <optional>
2221
#include <tuple>

include/phasar/Utils/BitVectorSet.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,11 @@ template <typename T> class BitVectorSet {
366366
}
367367
};
368368

369+
// Overloads with the other intersectWith functions from Utilities.h
370+
template <typename T>
371+
void intersectWith(BitVectorSet<T> &Dest, const BitVectorSet<T> &Src) {
372+
Dest.setIntersectWith(Src);
373+
}
369374
} // namespace psr
370375

371376
namespace std {

0 commit comments

Comments
 (0)